mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 18:48:45 -05:00
Moves type to GitCommit for better consistency
This commit is contained in:
@@ -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 the line is uncommitted, find the previous commit and treat it as a DiffWithWorking
|
||||||
if (commit.isUncommitted) {
|
if (commit.isUncommitted) {
|
||||||
uri = commit.uri;
|
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;
|
line = (blame.line.line + 1) + gitUri.offset;
|
||||||
return commands.executeCommand(Commands.DiffWithWorking, uri, commit, line);
|
return commands.executeCommand(Commands.DiffWithWorking, uri, commit, line);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
|
|||||||
commit = blame.commit;
|
commit = blame.commit;
|
||||||
// If the line is uncommitted, find the previous commit
|
// If the line is uncommitted, find the previous commit
|
||||||
if (commit.isUncommitted) {
|
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;
|
line = blame.line.line + 1 + gitUri.offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
|||||||
let commit = blame.commit;
|
let commit = blame.commit;
|
||||||
// If the line is uncommitted, find the previous commit
|
// If the line is uncommitted, find the previous commit
|
||||||
if (commit.isUncommitted) {
|
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);
|
const remotes = Arrays.uniqueBy(await this.git.getRemotes(this.repoPath), _ => _.url, _ => !!_.provider);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export interface IGitAuthor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IGitCommit {
|
export interface IGitCommit {
|
||||||
|
type: GitCommitType;
|
||||||
repoPath: string;
|
repoPath: string;
|
||||||
sha: string;
|
sha: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
@@ -33,8 +34,11 @@ export interface IGitCommitLine {
|
|||||||
code?: string;
|
code?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type GitCommitType = 'blame' | 'file' | 'repo';
|
||||||
|
|
||||||
export class GitCommit implements IGitCommit {
|
export class GitCommit implements IGitCommit {
|
||||||
|
|
||||||
|
type: GitCommitType;
|
||||||
lines: IGitCommitLine[];
|
lines: IGitCommitLine[];
|
||||||
originalFileName?: string;
|
originalFileName?: string;
|
||||||
previousSha?: string;
|
previousSha?: string;
|
||||||
@@ -43,6 +47,7 @@ export class GitCommit implements IGitCommit {
|
|||||||
private _isUncommitted: boolean | undefined;
|
private _isUncommitted: boolean | undefined;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
type: GitCommitType,
|
||||||
public repoPath: string,
|
public repoPath: string,
|
||||||
public sha: string,
|
public sha: string,
|
||||||
public fileName: string,
|
public fileName: string,
|
||||||
@@ -54,6 +59,7 @@ export class GitCommit implements IGitCommit {
|
|||||||
previousSha?: string,
|
previousSha?: string,
|
||||||
previousFileName?: string
|
previousFileName?: string
|
||||||
) {
|
) {
|
||||||
|
this.type = type;
|
||||||
this.fileName = this.fileName && this.fileName.replace(/, ?$/, '');
|
this.fileName = this.fileName && this.fileName.replace(/, ?$/, '');
|
||||||
|
|
||||||
this.lines = lines || [];
|
this.lines = lines || [];
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Uri } from 'vscode';
|
import { Uri } from 'vscode';
|
||||||
import { GitCommit, IGitCommitLine } from './commit';
|
import { GitCommit, GitCommitType, IGitCommitLine } from './commit';
|
||||||
import { IGitStatusFile, GitStatusFileStatus } from './status';
|
import { IGitStatusFile, GitStatusFileStatus } from './status';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export type GitLogType = 'file' | 'repo';
|
|
||||||
|
|
||||||
export class GitLogCommit extends GitCommit {
|
export class GitLogCommit extends GitCommit {
|
||||||
|
|
||||||
fileNames: string;
|
fileNames: string;
|
||||||
@@ -15,7 +13,7 @@ export class GitLogCommit extends GitCommit {
|
|||||||
parentShas: string[];
|
parentShas: string[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public type: GitLogType,
|
type: GitCommitType,
|
||||||
repoPath: string,
|
repoPath: string,
|
||||||
sha: string,
|
sha: string,
|
||||||
fileName: string,
|
fileName: string,
|
||||||
@@ -29,7 +27,7 @@ export class GitLogCommit extends GitCommit {
|
|||||||
previousSha?: string,
|
previousSha?: string,
|
||||||
previousFileName?: 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;
|
this.fileNames = this.fileName;
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ export class GitBlameParser {
|
|||||||
authors.set(entry.author, author);
|
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) {
|
if (relativeFileName !== entry.fileName) {
|
||||||
commit.originalFileName = entry.fileName;
|
commit.originalFileName = entry.fileName;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Range } from 'vscode';
|
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 { Logger } from '../../logger';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@@ -29,7 +29,7 @@ const diffRegex = /diff --git a\/(.*) b\/(.*)/;
|
|||||||
|
|
||||||
export class GitLogParser {
|
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;
|
if (!data) return undefined;
|
||||||
|
|
||||||
const lines = data.split('\n');
|
const lines = data.split('\n');
|
||||||
@@ -164,7 +164,7 @@ export class GitLogParser {
|
|||||||
return entries;
|
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);
|
const entries = this._parseEntries(data, type, maxCount, reverse);
|
||||||
if (!entries) return undefined;
|
if (!entries) return undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ export class GitService extends Disposable {
|
|||||||
blame.commits.forEach(c => {
|
blame.commits.forEach(c => {
|
||||||
if (!shas.has(c.sha)) return;
|
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);
|
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);
|
commits.set(c.sha, commit);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Iterables } from '../system';
|
|||||||
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
|
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
|
||||||
import { Commands, Keyboard } from '../commands';
|
import { Commands, Keyboard } from '../commands';
|
||||||
import { Git, GitStatusFile, GitUri, IGitStatus } from '../gitService';
|
import { Git, GitStatusFile, GitUri, IGitStatus } from '../gitService';
|
||||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from './quickPicks';
|
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from '../quickPicks';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
||||||
|
|||||||
Reference in New Issue
Block a user