mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-15 17:25:33 -05:00
Adds compare with branch command
Adds branches quick pick
This commit is contained in:
@@ -57,7 +57,7 @@ export class Git {
|
||||
return data;
|
||||
}
|
||||
|
||||
static async getVersionedFile(fileName: string, repoPath: string, branchOrSha: string) {
|
||||
static async getVersionedFile(repoPath: string, fileName: string, branchOrSha: string) {
|
||||
const data = await Git.show(repoPath, fileName, branchOrSha);
|
||||
|
||||
const suffix = Git.isSha(branchOrSha) ? branchOrSha.substring(0, 8) : branchOrSha;
|
||||
@@ -70,7 +70,7 @@ export class Git {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.log(`getVersionedFile(${fileName}, ${repoPath}, ${branchOrSha}); destination=${destination}`);
|
||||
Logger.log(`getVersionedFile('${repoPath}', '${fileName}', ${branchOrSha}); destination=${destination}`);
|
||||
fs.appendFile(destination, data, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
@@ -127,6 +127,12 @@ export class Git {
|
||||
return gitCommand(root, ...params, `--`, file);
|
||||
}
|
||||
|
||||
static branch(repoPath: string) {
|
||||
const params = [`branch`, `-a`];
|
||||
|
||||
return gitCommand(repoPath, ...params);
|
||||
}
|
||||
|
||||
static diff_nameStatus(repoPath: string, sha1?: string, sha2?: string) {
|
||||
const params = [`diff`, `--name-status`, `-M`];
|
||||
if (sha1) {
|
||||
|
||||
@@ -209,4 +209,32 @@ const statusOcticonsMap = {
|
||||
};
|
||||
export function getGitStatusIcon(status: GitFileStatus, missing: string = '\u00a0\u00a0\u00a0\u00a0'): string {
|
||||
return statusOcticonsMap[status] || missing;
|
||||
}
|
||||
|
||||
export class GitBranch {
|
||||
|
||||
current: boolean;
|
||||
name: string;
|
||||
remote: boolean;
|
||||
|
||||
constructor(branch: string) {
|
||||
branch = branch.trim();
|
||||
|
||||
if (branch.startsWith('* ')) {
|
||||
branch = branch.substring(2);
|
||||
this.current = true;
|
||||
}
|
||||
|
||||
if (branch.startsWith('remotes/')) {
|
||||
branch = branch.substring(8);
|
||||
this.remote = true;
|
||||
}
|
||||
|
||||
const index = branch.indexOf(' ');
|
||||
if (index !== -1) {
|
||||
branch = branch.substring(0, index);
|
||||
}
|
||||
|
||||
this.name = branch;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user