From 378415839bebdf88a8142666a995d174bdbcebad Mon Sep 17 00:00:00 2001 From: Eryk Kolodziej Date: Fri, 19 May 2023 14:32:41 +0200 Subject: [PATCH] fix: add support for repository suffix and add "/-" as GitLab repo suffix --- index.js | 4 ++-- lib/hosts-config.js | 1 + test/integration.test.js | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index f2e4b717..4e5f587b 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,7 @@ export async function generateNotes(pluginConfig, context) { protocol = protocol && /http[^s]/.test(protocol) ? "http" : "https"; const [, owner, repository] = /^\/(?[^/]+)?\/?(?.+)?$/.exec(pathname); - const { issue, commit, referenceActions, issuePrefixes } = + const { issue, commit, referenceActions, issuePrefixes, repositoryPathSuffix } = find(HOSTS_CONFIG, (conf) => conf.hostname === hostname) || HOSTS_CONFIG.default; const parsedCommits = filter( commits @@ -66,7 +66,7 @@ export async function generateNotes(pluginConfig, context) { version: nextRelease.version, host: format({ protocol, hostname, port }), owner, - repository, + repository: repositoryPathSuffix ? `${repository}${repositoryPathSuffix}` : repository, previousTag, currentTag, linkCompare: currentTag && previousTag, diff --git a/lib/hosts-config.js b/lib/hosts-config.js index 9f996d79..50348c62 100644 --- a/lib/hosts-config.js +++ b/lib/hosts-config.js @@ -32,6 +32,7 @@ export default { commit: "commit", referenceActions: ["close", "closes", "closed", "closing", "fix", "fixes", "fixed", "fixing"], issuePrefixes: ["#"], + repositoryPathSuffix: "/-", }, default: { issue: "issues", diff --git a/test/integration.test.js b/test/integration.test.js index 4764c316..f01d132b 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -478,20 +478,20 @@ test.serial("Accept a Gitlab repository URL", async (t) => { { cwd, options: { repositoryUrl: "git+https://gitlab.com/owner/repo" }, lastRelease, nextRelease, commits } ); - t.regex(changelog, new RegExp(escape("(https://gitlab.com/owner/repo/compare/v1.0.0...v2.0.0)"))); + t.regex(changelog, new RegExp(escape("(https://gitlab.com/owner/repo/-/compare/v1.0.0...v2.0.0)"))); t.regex(changelog, /### Bug Fixes/); t.regex( changelog, new RegExp( escape( - "* **scope1:** First fix ([111](https://gitlab.com/owner/repo/commit/111)), closes [#10](https://gitlab.com/owner/repo/issues/10)" + "* **scope1:** First fix ([111](https://gitlab.com/owner/repo/-/commit/111)), closes [#10](https://gitlab.com/owner/repo/-/issues/10)" ) ) ); t.regex(changelog, /### Features/); t.regex( changelog, - new RegExp(escape("* **scope2:** Second feature ([222](https://gitlab.com/owner/repo/commit/222))")) + new RegExp(escape("* **scope2:** Second feature ([222](https://gitlab.com/owner/repo/-/commit/222))")) ); });