Adds compare with branch command

Adds branches quick pick
This commit is contained in:
Eric Amodio
2017-03-18 02:01:25 -04:00
parent 164cb2bfe0
commit 73bbbc1d5f
10 changed files with 149 additions and 5 deletions

View File

@@ -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) {

View File

@@ -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;
}
}