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:
53
src/git/models/logCommit.ts
Normal file
53
src/git/models/logCommit.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
import { Uri } from 'vscode';
|
||||
import { GitCommit, IGitCommitLine } from './commit';
|
||||
import { GitStatusFileStatus } from './status';
|
||||
import * as path from 'path';
|
||||
|
||||
export type GitLogType = 'file' | 'repo';
|
||||
|
||||
export class GitLogCommit extends GitCommit {
|
||||
|
||||
fileNames: string;
|
||||
fileStatuses: { status: GitStatusFileStatus, fileName: string, originalFileName?: string }[];
|
||||
nextSha?: string;
|
||||
nextFileName?: string;
|
||||
status: GitStatusFileStatus;
|
||||
|
||||
constructor(
|
||||
public type: GitLogType,
|
||||
repoPath: string,
|
||||
sha: string,
|
||||
fileName: string,
|
||||
author: string,
|
||||
date: Date,
|
||||
message: string,
|
||||
status?: GitStatusFileStatus,
|
||||
fileStatuses?: { status: GitStatusFileStatus, fileName: string, originalFileName?: string }[],
|
||||
lines?: IGitCommitLine[],
|
||||
originalFileName?: string,
|
||||
previousSha?: string,
|
||||
previousFileName?: string
|
||||
) {
|
||||
super(repoPath, sha, fileName, author, date, message, lines, originalFileName, previousSha, previousFileName);
|
||||
this.status = status;
|
||||
|
||||
this.fileNames = this.fileName;
|
||||
|
||||
if (fileStatuses) {
|
||||
this.fileStatuses = fileStatuses.filter(_ => !!_.fileName);
|
||||
this.fileName = this.fileStatuses[0].fileName;
|
||||
}
|
||||
else {
|
||||
this.fileStatuses = [{ status: status, fileName: fileName }];
|
||||
}
|
||||
}
|
||||
|
||||
get nextShortSha() {
|
||||
return this.nextSha && this.nextSha.substring(0, 8);
|
||||
}
|
||||
|
||||
get nextUri(): Uri {
|
||||
return this.nextFileName ? Uri.file(path.resolve(this.repoPath, this.nextFileName)) : this.uri;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user