mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-16 01:25:42 -05:00
Moves type to GitCommit for better consistency
This commit is contained in:
@@ -9,6 +9,7 @@ export interface IGitAuthor {
|
||||
}
|
||||
|
||||
export interface IGitCommit {
|
||||
type: GitCommitType;
|
||||
repoPath: string;
|
||||
sha: string;
|
||||
fileName: string;
|
||||
@@ -33,8 +34,11 @@ export interface IGitCommitLine {
|
||||
code?: string;
|
||||
}
|
||||
|
||||
export type GitCommitType = 'blame' | 'file' | 'repo';
|
||||
|
||||
export class GitCommit implements IGitCommit {
|
||||
|
||||
type: GitCommitType;
|
||||
lines: IGitCommitLine[];
|
||||
originalFileName?: string;
|
||||
previousSha?: string;
|
||||
@@ -43,6 +47,7 @@ export class GitCommit implements IGitCommit {
|
||||
private _isUncommitted: boolean | undefined;
|
||||
|
||||
constructor(
|
||||
type: GitCommitType,
|
||||
public repoPath: string,
|
||||
public sha: string,
|
||||
public fileName: string,
|
||||
@@ -54,6 +59,7 @@ export class GitCommit implements IGitCommit {
|
||||
previousSha?: string,
|
||||
previousFileName?: string
|
||||
) {
|
||||
this.type = type;
|
||||
this.fileName = this.fileName && this.fileName.replace(/, ?$/, '');
|
||||
|
||||
this.lines = lines || [];
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
'use strict';
|
||||
import { Uri } from 'vscode';
|
||||
import { GitCommit, IGitCommitLine } from './commit';
|
||||
import { GitCommit, GitCommitType, IGitCommitLine } from './commit';
|
||||
import { IGitStatusFile, GitStatusFileStatus } from './status';
|
||||
import * as path from 'path';
|
||||
|
||||
export type GitLogType = 'file' | 'repo';
|
||||
|
||||
export class GitLogCommit extends GitCommit {
|
||||
|
||||
fileNames: string;
|
||||
@@ -15,7 +13,7 @@ export class GitLogCommit extends GitCommit {
|
||||
parentShas: string[];
|
||||
|
||||
constructor(
|
||||
public type: GitLogType,
|
||||
type: GitCommitType,
|
||||
repoPath: string,
|
||||
sha: string,
|
||||
fileName: string,
|
||||
@@ -29,7 +27,7 @@ export class GitLogCommit extends GitCommit {
|
||||
previousSha?: string,
|
||||
previousFileName?: string
|
||||
) {
|
||||
super(repoPath, sha, fileName, author, date, message, lines, originalFileName, previousSha, previousFileName);
|
||||
super(type, repoPath, sha, fileName, author, date, message, lines, originalFileName, previousSha, previousFileName);
|
||||
|
||||
this.fileNames = this.fileName;
|
||||
|
||||
|
||||
@@ -146,7 +146,7 @@ export class GitBlameParser {
|
||||
authors.set(entry.author, author);
|
||||
}
|
||||
|
||||
commit = new GitCommit(repoPath, entry.sha, relativeFileName, entry.author, moment(`${entry.authorDate} ${entry.authorTimeZone}`, 'X +-HHmm').toDate(), entry.summary);
|
||||
commit = new GitCommit('blame', repoPath, entry.sha, relativeFileName, entry.author, moment(`${entry.authorDate} ${entry.authorTimeZone}`, 'X +-HHmm').toDate(), entry.summary);
|
||||
|
||||
if (relativeFileName !== entry.fileName) {
|
||||
commit.originalFileName = entry.fileName;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
import { Range } from 'vscode';
|
||||
import { Git, GitStatusFileStatus, GitLogCommit, GitLogType, IGitAuthor, IGitLog, IGitStatusFile } from './../git';
|
||||
import { Git, GitStatusFileStatus, GitLogCommit, GitCommitType, IGitAuthor, IGitLog, IGitStatusFile } from './../git';
|
||||
// import { Logger } from '../../logger';
|
||||
import * as moment from 'moment';
|
||||
import * as path from 'path';
|
||||
@@ -29,7 +29,7 @@ const diffRegex = /diff --git a\/(.*) b\/(.*)/;
|
||||
|
||||
export class GitLogParser {
|
||||
|
||||
private static _parseEntries(data: string, type: GitLogType, maxCount: number | undefined, reverse: boolean): ILogEntry[] {
|
||||
private static _parseEntries(data: string, type: GitCommitType, maxCount: number | undefined, reverse: boolean): ILogEntry[] {
|
||||
if (!data) return undefined;
|
||||
|
||||
const lines = data.split('\n');
|
||||
@@ -164,7 +164,7 @@ export class GitLogParser {
|
||||
return entries;
|
||||
}
|
||||
|
||||
static parse(data: string, type: GitLogType, repoPath: string | undefined, fileName: string | undefined, sha: string | undefined, maxCount: number | undefined, reverse: boolean, range: Range): IGitLog {
|
||||
static parse(data: string, type: GitCommitType, repoPath: string | undefined, fileName: string | undefined, sha: string | undefined, maxCount: number | undefined, reverse: boolean, range: Range): IGitLog {
|
||||
const entries = this._parseEntries(data, type, maxCount, reverse);
|
||||
if (!entries) return undefined;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user