mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 11:08:34 -05:00
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
'use strict';
|
|
import { Range } from 'vscode';
|
|
import { RemoteProvider } from './provider';
|
|
|
|
export class BitbucketService extends RemoteProvider {
|
|
|
|
constructor(public domain: string, public path: string, public custom: boolean = false) {
|
|
super(domain, path);
|
|
}
|
|
|
|
get name() {
|
|
return this.formatName('Bitbucket');
|
|
}
|
|
|
|
protected getUrlForBranches(): string {
|
|
return `${this.baseUrl}/branches`;
|
|
}
|
|
|
|
protected getUrlForBranch(branch: string): string {
|
|
return `${this.baseUrl}/commits/branch/${branch}`;
|
|
}
|
|
|
|
protected getUrlForCommit(sha: string): string {
|
|
return `${this.baseUrl}/commits/${sha}`;
|
|
}
|
|
|
|
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
|
|
let line = '';
|
|
if (range) {
|
|
if (range.start.line === range.end.line) {
|
|
line = `#${fileName}-${range.start.line}`;
|
|
}
|
|
else {
|
|
line = `#${fileName}-${range.start.line}:${range.end.line}`;
|
|
}
|
|
}
|
|
|
|
if (sha) return `${this.baseUrl}/src/${sha}/${fileName}${line}`;
|
|
if (branch) return `${this.baseUrl}/src/${branch}/${fileName}${line}`;
|
|
return `${this.baseUrl}?path=${fileName}${line}`;
|
|
}
|
|
} |