Parcourir la source

Moves type to GitCommit for better consistency

main
Eric Amodio il y a 7 ans
Parent
révision
aa39792843
9 fichiers modifiés avec 18 ajouts et 14 suppressions
  1. +1
    -1
      src/commands/diffLineWithPrevious.ts
  2. +1
    -1
      src/commands/diffLineWithWorking.ts
  3. +1
    -1
      src/commands/openCommitInRemote.ts
  4. +6
    -0
      src/git/models/commit.ts
  5. +3
    -5
      src/git/models/logCommit.ts
  6. +1
    -1
      src/git/parsers/blameParser.ts
  7. +3
    -3
      src/git/parsers/logParser.ts
  8. +1
    -1
      src/gitService.ts
  9. +1
    -1
      src/quickPicks/repoStatus.ts

+ 1
- 1
src/commands/diffLineWithPrevious.ts Voir le fichier

@ -43,7 +43,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
// If the line is uncommitted, find the previous commit and treat it as a DiffWithWorking
if (commit.isUncommitted) {
uri = commit.uri;
commit = new GitCommit(commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
line = (blame.line.line + 1) + gitUri.offset;
return commands.executeCommand(Commands.DiffWithWorking, uri, commit, line);
}

+ 1
- 1
src/commands/diffLineWithWorking.ts Voir le fichier

@ -34,7 +34,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
commit = blame.commit;
// If the line is uncommitted, find the previous commit
if (commit.isUncommitted) {
commit = new GitCommit(commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
line = blame.line.line + 1 + gitUri.offset;
}
}

+ 1
- 1
src/commands/openCommitInRemote.ts Voir le fichier

@ -32,7 +32,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
let commit = blame.commit;
// If the line is uncommitted, find the previous commit
if (commit.isUncommitted) {
commit = new GitCommit(commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
}
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.repoPath), _ => _.url, _ => !!_.provider);

+ 6
- 0
src/git/models/commit.ts Voir le fichier

@ -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 || [];

+ 3
- 5
src/git/models/logCommit.ts Voir le fichier

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

+ 1
- 1
src/git/parsers/blameParser.ts Voir le fichier

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

+ 3
- 3
src/git/parsers/logParser.ts Voir le fichier

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

+ 1
- 1
src/gitService.ts Voir le fichier

@ -435,7 +435,7 @@ export class GitService extends Disposable {
blame.commits.forEach(c => {
if (!shas.has(c.sha)) return;
const commit: GitCommit = new GitCommit(c.repoPath, c.sha, c.fileName, c.author, c.date, c.message,
const commit: GitCommit = new GitCommit('blame', c.repoPath, c.sha, c.fileName, c.author, c.date, c.message,
c.lines.filter(l => l.line >= range.start.line && l.line <= range.end.line), c.originalFileName, c.previousSha, c.previousFileName);
commits.set(c.sha, commit);

+ 1
- 1
src/quickPicks/repoStatus.ts Voir le fichier

@ -3,7 +3,7 @@ import { Iterables } from '../system';
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
import { Commands, Keyboard } from '../commands';
import { Git, GitStatusFile, GitUri, IGitStatus } from '../gitService';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from './quickPicks';
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from '../quickPicks';
import * as path from 'path';
export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {

Chargement…
Annuler
Enregistrer