Add support for opening a BitBucket branch remotely

This commit is contained in:
GitButler 2024-03-29 17:04:16 +01:00
parent fe36d83b8e
commit 1516dd1095

View File

@ -288,11 +288,11 @@ export class BaseBranch {
} }
commitUrl(commitId: string): string | undefined { commitUrl(commitId: string): string | undefined {
// if repoBaseUrl is bitbucket, then the commit url is different // Different Git providers use different paths for the commit url:
if (this.repoBaseUrl.includes('bitbucket.org')) { if (this.isBitBucket) {
return `${this.repoBaseUrl}/commits/${commitId}`; return `${this.repoBaseUrl}/commits/${commitId}`;
} }
if (this.repoBaseUrl.includes('gitlab.com')) { if (this.isGitlab) {
return `${this.repoBaseUrl}/-/commit/${commitId}`; return `${this.repoBaseUrl}/-/commit/${commitId}`;
} }
return `${this.repoBaseUrl}/commit/${commitId}`; return `${this.repoBaseUrl}/commit/${commitId}`;
@ -306,6 +306,18 @@ export class BaseBranch {
if (!upstreamBranchName) return undefined; if (!upstreamBranchName) return undefined;
const baseBranchName = this.branchName.split('/')[1]; const baseBranchName = this.branchName.split('/')[1];
const branchName = upstreamBranchName.split('/').slice(3).join('/'); const branchName = upstreamBranchName.split('/').slice(3).join('/');
if (this.isBitBucket) {
return `${this.repoBaseUrl.trim()}/branch/${branchName}?dest=${baseBranchName}`;
}
// The following branch path is good for at least Gitlab and Github:
return `${this.repoBaseUrl.trim()}/compare/${baseBranchName}...${branchName}`; return `${this.repoBaseUrl.trim()}/compare/${baseBranchName}...${branchName}`;
} }
private get isBitBucket(): boolean {
return this.repoBaseUrl.includes('bitbucket.org');
}
private get isGitlab(): boolean {
return this.repoBaseUrl.includes('gitlab.com');
}
} }