一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
37 行
1.4 KiB
TypeScript
37 行
1.4 KiB
TypeScript
import { rtrimSlashes } from '@joplin/lib/path-utils';
|
|
import { PluginManifest } from '@joplin/lib/services/plugins/utils/types';
|
|
|
|
function removeBranch(commit: string): string {
|
|
if (!commit) return '';
|
|
|
|
if (commit.indexOf(':') >= 0) {
|
|
const s = commit.split(':');
|
|
return s[1];
|
|
}
|
|
|
|
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: Pick<PluginManifest, 'repository_url' | '_publish_commit'>, previousManifest: Pick<PluginManifest, '_publish_commit'> | null = 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 = formatRepoUrl(manifest.repository_url);
|
|
const commit: string = removeBranch(manifest._publish_commit);
|
|
const previousCommit: string = previousManifest ? removeBranch(previousManifest._publish_commit) : '';
|
|
|
|
if (!repoUrl) return null;
|
|
if (!commit && !previousCommit) return repoUrl;
|
|
if (commit && !previousCommit) return `${rtrimSlashes(repoUrl)}/tree/${commit}`;
|
|
|
|
return `${rtrimSlashes(repoUrl)}/compare/${previousCommit}..${commit}`;
|
|
}
|