diff --git a/packages/plugin-repo-cli/lib/gitCompareUrl.test.ts b/packages/plugin-repo-cli/lib/gitCompareUrl.test.ts index c756c5d2b..3ac15d6a1 100644 --- a/packages/plugin-repo-cli/lib/gitCompareUrl.test.ts +++ b/packages/plugin-repo-cli/lib/gitCompareUrl.test.ts @@ -15,6 +15,17 @@ describe('gitCompareUrl', () => { }, 'https://github.com/JackGruber/joplin-plugin-copytags/compare/b52b01f6d3b709a811ac214253636a7c207c87dd..9ec4a476a54440ac43422c34e179dcabfca1e5a0', ], + [ + { + repository_url: 'https://github.com/JackGruber/joplin-plugin-copytags.git', + _publish_commit: 'master:9ec4a476a54440ac43422c34e179dcabfca1e5a0', + }, + { + repository_url: 'https://github.com/JackGruber/joplin-plugin-copytags.git', + _publish_commit: 'master:b52b01f6d3b709a811ac214253636a7c207c87dd', + }, + 'https://github.com/JackGruber/joplin-plugin-copytags/compare/b52b01f6d3b709a811ac214253636a7c207c87dd..9ec4a476a54440ac43422c34e179dcabfca1e5a0', + ], [ { repository_url: 'https://github.com/JackGruber/joplin-plugin-copytags', diff --git a/packages/plugin-repo-cli/lib/gitCompareUrl.ts b/packages/plugin-repo-cli/lib/gitCompareUrl.ts index 303b3301b..2017e988c 100644 --- a/packages/plugin-repo-cli/lib/gitCompareUrl.ts +++ b/packages/plugin-repo-cli/lib/gitCompareUrl.ts @@ -11,13 +11,19 @@ function removeBranch(commit: string): string { return commit; } +const formatRepoUrl = (url: string): string => { + if (!url) return url; + if (url.endsWith('.git')) return url.substring(0, url.length - 4); + return url; +}; + export default function(manifest: any, previousManifest: any = null): string { // "repository_url": "https://github.com/JackGruber/joplin-plugin-copytags", // "_publish_commit": "master:b52b01f6d3b709a811ac214253636a7c207c87dd", // https://github.com/JackGruber/joplin-plugin-copytags/compare/9ec4a476a54440ac43422c34e179dcabfca1e5a0..b52b01f6d3b709a811ac214253636a7c207c87dd - const repoUrl: string = manifest.repository_url; + const repoUrl: string = formatRepoUrl(manifest.repository_url); const commit: string = removeBranch(manifest._publish_commit); const previousCommit: string = previousManifest ? removeBranch(previousManifest._publish_commit) : '';