From 687e2e23595935ebb7ed54167386ed58d6f3766d Mon Sep 17 00:00:00 2001 From: Gianluigi Crispino <39495999+giacris82@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:26:54 +0100 Subject: [PATCH] fix: AWS CodeCommit compatibility (#748) --- index.js | 2 +- test/integration.test.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6377eae7..a3efe594 100644 --- a/index.js +++ b/index.js @@ -39,7 +39,7 @@ export async function generateNotes(pluginConfig, context) { ); port = protocol.includes("ssh") ? "" : port; protocol = protocol && /http[^s]/.test(protocol) ? "http" : "https"; - const [, owner, repository] = /^\/(?[^/]+)?\/?(?.+)?$/.exec(pathname); + const [, owner, repository] = /^\/(?[^/]+)?\/?(?.+)?$/.exec(pathname) || []; const { issue, commit, referenceActions, issuePrefixes } = find(HOSTS_CONFIG, (conf) => conf.hostname === hostname) || HOSTS_CONFIG.default; diff --git a/test/integration.test.js b/test/integration.test.js index 0dc2bb83..29c39822 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -686,3 +686,28 @@ test.serial('ReThrow error from "conventional-changelog"', async (t) => { { message: "Test error" } ); }); + +test("Accept a custom AWS CodeCommit repository URL", async (t) => { + const { generateNotes } = await import("../index.js"); + const commits = [ + { hash: "111", message: "fix(scope1): First fix" }, + { hash: "222", message: "feat(scope2): Second feature" }, + ]; + const changelog = await generateNotes( + {}, + { + cwd, + options: { + repositoryUrl: "codecommit::eu-central-1://profile@repository-name", + }, + lastRelease, + nextRelease, + commits, + } + ); + + t.regex(changelog, /### Bug Fixes/); + t.regex(changelog, new RegExp(escape("* **scope1:** First fix 111"))); + t.regex(changelog, /### Features/); + t.regex(changelog, new RegExp(escape("* **scope2:** Second feature 222"))); +});