mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 02:58:32 -05:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
'use strict';
|
|
import { Range } from 'vscode';
|
|
import { RemoteProvider } from './provider';
|
|
|
|
export class BitbucketServerService extends RemoteProvider {
|
|
|
|
constructor(public domain: string, public path: string, public custom: boolean = false) {
|
|
super(domain, path);
|
|
}
|
|
|
|
get name() {
|
|
return this.formatName('Bitbucket Server');
|
|
}
|
|
|
|
protected get baseUrl() {
|
|
const [project, repo] = super.splitPath();
|
|
return `https://${this.domain}/projects/${project}/repos/${repo}`;
|
|
}
|
|
|
|
protected getUrlForBranches(): string {
|
|
return `${this.baseUrl}/branches`;
|
|
}
|
|
|
|
protected getUrlForBranch(branch: string): string {
|
|
return `${this.baseUrl}/commits?until=${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 = `#${range.start.line}`;
|
|
}
|
|
else {
|
|
line = `#${range.start.line}-${range.end.line}`;
|
|
}
|
|
}
|
|
|
|
if (sha) return `${this.baseUrl}/browse/${fileName}?at=${sha}${line}`;
|
|
if (branch) return `${this.baseUrl}/browse/${fileName}?at=${branch}${line}`;
|
|
return `${this.baseUrl}/browse/${fileName}${line}`;
|
|
}
|
|
} |