Files
vscode-gitlens/src/git/remotes/visualStudio.ts
Eric Amodio f58d085352 Adds Open Branches in Remote command
Adds Open Branches in Remote command to the Branches custom view item
Adds Open Repository in Remote command to the Repository Status custom view item
2017-09-03 15:37:52 -04:00

42 lines
1.3 KiB
TypeScript

'use strict';
import { Range } from 'vscode';
import { RemoteProvider } from './provider';
export class VisualStudioService extends RemoteProvider {
constructor(public domain: string, public path: string) {
super(domain, path);
}
get name() {
return 'Visual Studio Team Services';
}
protected getUrlForBranches(): string {
return `${this.baseUrl}/branches`;
}
protected getUrlForBranch(branch: string): string {
return `${this.baseUrl}/?version=GB${branch}&_a=history`;
}
protected getUrlForCommit(sha: string): string {
return `${this.baseUrl}/commit/${sha}`;
}
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
let line = '';
if (range) {
if (range.start.line === range.end.line) {
line = `&line=${range.start.line}`;
}
else {
line = `&line=${range.start.line}&lineEnd=${range.end.line}`;
}
}
if (sha) return `${this.baseUrl}/commit/${sha}/?_a=contents&path=%2F${fileName}${line}`;
if (branch) return `${this.baseUrl}/?path=%2F${fileName}&version=GB${branch}&_a=contents${line}`;
return `${this.baseUrl}?path=%2F${fileName}${line}`;
}
}