mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-15 01:25:42 -05:00
Refactors git models & parsers
Adds full git status parsing Adds git status info into status quick pick Switches to async/await in file blame/log
This commit is contained in:
45
src/git/models/status.ts
Normal file
45
src/git/models/status.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
export interface IGitStatus {
|
||||
|
||||
branch: string;
|
||||
repoPath: string;
|
||||
sha: string;
|
||||
state: {
|
||||
ahead: number;
|
||||
behind: number;
|
||||
};
|
||||
upstream?: string;
|
||||
|
||||
files: GitStatusFile[];
|
||||
}
|
||||
|
||||
export declare type GitStatusFileStatus = '!' | '?' | 'A' | 'C' | 'D' | 'M' | 'R' | 'U';
|
||||
|
||||
export class GitStatusFile {
|
||||
|
||||
originalFileName?: string;
|
||||
|
||||
constructor(public repoPath: string, public status: GitStatusFileStatus, public staged: boolean, public fileName: string, originalFileName?: string) {
|
||||
this.originalFileName = originalFileName;
|
||||
}
|
||||
|
||||
getIcon() {
|
||||
return getGitStatusIcon(this.status);
|
||||
}
|
||||
}
|
||||
|
||||
const statusOcticonsMap = {
|
||||
'!': '$(diff-ignored)',
|
||||
'?': '$(diff-added)',
|
||||
A: '$(diff-added)',
|
||||
C: '$(diff-added)',
|
||||
D: '$(diff-removed)',
|
||||
M: '$(diff-modified)',
|
||||
R: '$(diff-renamed)',
|
||||
U: '$(question)'
|
||||
};
|
||||
|
||||
export function getGitStatusIcon(status: GitStatusFileStatus, missing: string = '\u00a0\u00a0\u00a0\u00a0'): string {
|
||||
return statusOcticonsMap[status] || missing;
|
||||
}
|
||||
Reference in New Issue
Block a user