Skip to content

Commit adb79c0

Browse files
committed
fix: ignore custom port when converting ssh repo URL to https
1 parent ba1b7a8 commit adb79c0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ async function generateNotes(pluginConfig, context) {
3535
let {hostname, port, pathname, protocol} = new URL(
3636
match ? `ssh://${auth ? `${auth}@` : ''}${host}/${path}` : repositoryUrl
3737
);
38+
port = protocol.includes('ssh') ? '' : port;
3839
protocol = protocol && /http[^s]/.test(protocol) ? 'http' : 'https';
3940
const [, owner, repository] = /^\/([^/]+)?\/?(.+)?$/.exec(pathname);
4041

test/integration.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,26 @@ test('Accept a custom repository URL with git+https format', async t => {
382382
);
383383
});
384384

385+
test('Accept a custom repository URL with git+ssh format and custom port', async t => {
386+
const commits = [
387+
{hash: '111', message: 'fix(scope1): First fix'},
388+
{hash: '222', message: 'feat(scope2): Second feature'},
389+
];
390+
const changelog = await generateNotes(
391+
{},
392+
{cwd, options: {repositoryUrl: 'git+ssh://git@domain.com:2222/owner/repo.git'}, lastRelease, nextRelease, commits}
393+
);
394+
395+
t.regex(changelog, new RegExp(escape('(https://domain.com/owner/repo/compare/v1.0.0...v2.0.0)')));
396+
t.regex(changelog, /### Bug Fixes/);
397+
t.regex(changelog, new RegExp(escape('* **scope1:** First fix ([111](https://domain.com/owner/repo/commit/111))')));
398+
t.regex(changelog, /### Features/);
399+
t.regex(
400+
changelog,
401+
new RegExp(escape('* **scope2:** Second feature ([222](https://domain.com/owner/repo/commit/222))'))
402+
);
403+
});
404+
385405
test('Accept a Bitbucket repository URL', async t => {
386406
const commits = [
387407
{hash: '111', message: 'fix(scope1): First fix\n\nResolves #10'},

0 commit comments

Comments
 (0)