Переглянути джерело

Renames getLogCommit* methods

Removes getRecentLogCommitForFile
main
Eric Amodio 5 роки тому
джерело
коміт
818242c6c6
19 змінених файлів з 66 додано та 66 видалено
  1. +1
    -1
      src/annotations/blameAnnotationProvider.ts
  2. +1
    -1
      src/annotations/recentChangesAnnotationProvider.ts
  3. +1
    -1
      src/commands/copyMessageToClipboard.ts
  4. +1
    -1
      src/commands/copyRemoteFileUrlToClipboard.ts
  5. +2
    -2
      src/commands/diffWithWorking.ts
  6. +6
    -1
      src/commands/openInRemote.ts
  7. +1
    -1
      src/commands/showQuickCommitFileDetails.ts
  8. +2
    -2
      src/git/formatters/commitFormatter.ts
  9. +33
    -38
      src/git/gitService.ts
  10. +4
    -4
      src/git/models/commit.ts
  11. +1
    -1
      src/git/models/logCommit.ts
  12. +5
    -5
      src/git/parsers/logParser.ts
  13. +1
    -1
      src/hovers/lineHoverController.ts
  14. +1
    -1
      src/quickpicks/commitFileQuickPick.ts
  15. +2
    -2
      src/quickpicks/repoStatusQuickPick.ts
  16. +1
    -1
      src/views/nodes/fileHistoryNode.ts
  17. +1
    -1
      src/views/nodes/lineHistoryNode.ts
  18. +1
    -1
      src/views/nodes/statusFilesNode.ts
  19. +1
    -1
      src/views/viewCommands.ts

+ 1
- 1
src/annotations/blameAnnotationProvider.ts Переглянути файл

@ -219,7 +219,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
// Get the full commit message -- since blame only returns the summary
let logCommit: GitCommit | undefined = undefined;
if (!commit.isUncommitted) {
logCommit = await Container.git.getLogCommitForFile(commit.repoPath, commit.uri.fsPath, {
logCommit = await Container.git.getCommitForFile(commit.repoPath, commit.uri.fsPath, {
ref: commit.sha
});
if (logCommit !== undefined) {

+ 1
- 1
src/annotations/recentChangesAnnotationProvider.ts Переглянути файл

@ -29,7 +29,7 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
this.annotationType = FileAnnotationType.RecentChanges;
const commit = await Container.git.getRecentLogCommitForFile(this._uri.repoPath, this._uri.fsPath);
const commit = await Container.git.getCommitForFile(this._uri.repoPath, this._uri.fsPath);
if (commit === undefined) return false;
const diff = await Container.git.getDiffForFile(this._uri, commit.sha);

+ 1
- 1
src/commands/copyMessageToClipboard.ts Переглянути файл

@ -83,7 +83,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
}
// Get the full commit message -- since blame only returns the summary
const commit = await Container.git.getLogCommit(gitUri.repoPath!, args.sha);
const commit = await Container.git.getCommit(gitUri.repoPath!, args.sha);
if (commit === undefined) return undefined;
args.message = commit.message;

+ 1
- 1
src/commands/copyRemoteFileUrlToClipboard.ts Переглянути файл

@ -54,7 +54,7 @@ export class CopyRemoteFileUrlToClipboardCommand extends ActiveEditorCommand {
args = { ...args };
if (gitUri.sha === undefined) {
const commit = await Container.git.getLogCommitForFile(gitUri.repoPath, gitUri.fsPath, {
const commit = await Container.git.getCommitForFile(gitUri.repoPath, gitUri.fsPath, {
firstIfNotFound: true
});

+ 2
- 2
src/commands/diffWithWorking.ts Переглянути файл

@ -68,7 +68,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
if (status !== undefined && status.indexStatus !== undefined) {
let sha = GitService.stagedUncommittedSha;
if (args.inDiffEditor) {
const commit = await Container.git.getRecentLogCommitForFile(gitUri.repoPath!, gitUri.fsPath);
const commit = await Container.git.getCommitForFile(gitUri.repoPath!, gitUri.fsPath);
if (commit === undefined) return Messages.showCommitHasNoPreviousCommitWarningMessage();
sha = commit.sha;
@ -99,7 +99,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
}
try {
args.commit = await Container.git.getLogCommitForFile(gitUri.repoPath, gitUri.fsPath, {
args.commit = await Container.git.getCommitForFile(gitUri.repoPath, gitUri.fsPath, {
ref: sha,
firstIfNotFound: true
});

+ 6
- 1
src/commands/openInRemote.ts Переглянути файл

@ -110,7 +110,12 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
}
private ensureRemoteBranchName(args: OpenInRemoteCommandArgs) {
if (args.remotes === undefined || args.resource === undefined || args.resource.type !== 'branch') return;
if (
args.remotes === undefined ||
args.resource === undefined ||
args.resource.type !== RemoteResourceType.Branch
)
return;
// Check to see if the remote is in the branch
const [remotePart, branchPart] = Strings.splitSingle(args.resource.branch, '/');

+ 1
- 1
src/commands/showQuickCommitFileDetails.ts Переглянути файл

@ -110,7 +110,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
if (args.fileLog === undefined) {
const repoPath = args.commit === undefined ? gitUri.repoPath : args.commit.repoPath;
args.commit = await Container.git.getLogCommitForFile(repoPath, gitUri.fsPath, { ref: args.sha });
args.commit = await Container.git.getCommitForFile(repoPath, gitUri.fsPath, { ref: args.sha });
if (args.commit === undefined) {
return Messages.showCommitNotFoundWarningMessage('Unable to show commit file details');
}

+ 2
- 2
src/git/formatters/commitFormatter.ts Переглянути файл

@ -145,7 +145,7 @@ export class CommitFormatter extends Formatter {
}
get changes() {
if (!(this._item instanceof GitLogCommit) || this._item.type === GitCommitType.File) {
if (!(this._item instanceof GitLogCommit) || this._item.type === GitCommitType.LogFile) {
return this._padOrTruncate(emptyStr, this._options.tokenOptions.changes);
}
@ -153,7 +153,7 @@ export class CommitFormatter extends Formatter {
}
get changesShort() {
if (!(this._item instanceof GitLogCommit) || this._item.type === GitCommitType.File) {
if (!(this._item instanceof GitLogCommit) || this._item.type === GitCommitType.LogFile) {
return this._padOrTruncate(emptyStr, this._options.tokenOptions.changesShort);
}

+ 33
- 38
src/git/gitService.ts Переглянути файл

@ -1011,6 +1011,36 @@ export class GitService implements Disposable {
}
@log()
async getCommit(repoPath: string, ref: string): Promise<GitLogCommit | undefined> {
const log = await this.getLog(repoPath, { maxCount: 2, ref: ref });
if (log === undefined) return undefined;
return log.commits.get(ref);
}
@log()
async getCommitForFile(
repoPath: string | undefined,
fileName: string,
options: { ref?: string; firstIfNotFound?: boolean; reverse?: boolean } = {}
): Promise<GitLogCommit | undefined> {
const log = await this.getLogForFile(repoPath, fileName, {
maxCount: 2,
ref: options.ref,
reverse: options.reverse
});
if (log === undefined) return undefined;
const commit = options.ref && log.commits.get(options.ref);
if (commit === undefined && !options.firstIfNotFound && options.ref) {
// If the ref isn't a valid sha we will never find it, so let it fall through so we return the first
if (!Git.isSha(options.ref) || Git.isUncommitted(options.ref)) return undefined;
}
return commit || Iterables.first(log.commits.values());
}
@log()
getConfig(key: string, repoPath?: string): Promise<string | undefined> {
return Git.config_get(key, repoPath);
}
@ -1236,41 +1266,6 @@ export class GitService implements Disposable {
}
@log()
getRecentLogCommitForFile(repoPath: string | undefined, fileName: string): Promise<GitLogCommit | undefined> {
return this.getLogCommitForFile(repoPath, fileName, undefined);
}
@log()
async getLogCommit(repoPath: string, ref: string): Promise<GitLogCommit | undefined> {
const log = await this.getLog(repoPath, { maxCount: 2, ref: ref });
if (log === undefined) return undefined;
return log.commits.get(ref);
}
@log()
async getLogCommitForFile(
repoPath: string | undefined,
fileName: string,
options: { ref?: string; firstIfNotFound?: boolean; reverse?: boolean } = {}
): Promise<GitLogCommit | undefined> {
const log = await this.getLogForFile(repoPath, fileName, {
maxCount: 2,
ref: options.ref,
reverse: options.reverse
});
if (log === undefined) return undefined;
const commit = options.ref && log.commits.get(options.ref);
if (commit === undefined && !options.firstIfNotFound && options.ref) {
// If the ref isn't a valid sha we will never find it, so let it fall through so we return the first
if (!Git.isSha(options.ref) || Git.isUncommitted(options.ref)) return undefined;
}
return commit || Iterables.first(log.commits.values());
}
@log()
async getLog(
repoPath: string,
{ ref, ...options }: { authors?: string[]; maxCount?: number; ref?: string; reverse?: boolean } = {}
@ -1286,7 +1281,7 @@ export class GitService implements Disposable {
});
const log = GitLogParser.parse(
data,
GitCommitType.Branch,
GitCommitType.Log,
repoPath,
undefined,
ref,
@ -1386,7 +1381,7 @@ export class GitService implements Disposable {
const data = await Git.log_search(repoPath, searchArgs, { maxCount: maxCount });
const log = GitLogParser.parse(
data,
GitCommitType.Branch,
GitCommitType.Log,
repoPath,
undefined,
undefined,
@ -1562,7 +1557,7 @@ export class GitService implements Disposable {
});
const log = GitLogParser.parse(
data,
GitCommitType.File,
GitCommitType.LogFile,
root,
file,
ref,

+ 4
- 4
src/git/models/commit.ts Переглянути файл

@ -23,10 +23,10 @@ export interface GitCommitLine {
export enum GitCommitType {
Blame = 'blame',
Branch = 'branch',
File = 'file',
Log = 'log',
LogFile = 'logFile',
Stash = 'stash',
StashFile = 'stash-file'
StashFile = 'stashFile'
}
export const CommitFormatting = {
@ -86,7 +86,7 @@ export abstract class GitCommit {
get isFile() {
return (
this.type === GitCommitType.Blame ||
this.type === GitCommitType.File ||
this.type === GitCommitType.LogFile ||
this.type === GitCommitType.StashFile
);
}

+ 1
- 1
src/git/models/logCommit.ts Переглянути файл

@ -162,7 +162,7 @@ export class GitLogCommit extends GitCommit {
const previousSha = this.isFile ? this.previousSha : `${this.sha}^`;
return this.with({
type: this.isStash ? GitCommitType.StashFile : GitCommitType.File,
type: this.isStash ? GitCommitType.StashFile : GitCommitType.LogFile,
sha: sha,
fileName: file.fileName,
originalFileName: file.originalFileName,

+ 5
- 5
src/git/parsers/logParser.ts Переглянути файл

@ -180,7 +180,7 @@ export class GitLogParser {
if (line.startsWith('warning:')) continue;
if (type === GitCommitType.Branch) {
if (type === GitCommitType.Log) {
match = fileStatusRegex.exec(line);
if (match != null) {
if (entry.files === undefined) {
@ -262,7 +262,7 @@ export class GitLogParser {
);
}
if (first && repoPath === undefined && type === GitCommitType.File && fileName !== undefined) {
if (first && repoPath === undefined && type === GitCommitType.LogFile && fileName !== undefined) {
// Try to get the repoPath from the most recent commit
repoPath = Strings.normalizePath(
fileName.replace(
@ -353,7 +353,7 @@ export class GitLogParser {
const originalFileName =
entry.originalFileName || (relativeFileName !== entry.fileName ? entry.fileName : undefined);
if (type === GitCommitType.File) {
if (type === GitCommitType.LogFile) {
entry.files = [
{
status: entry.status!,
@ -376,7 +376,7 @@ export class GitLogParser {
entry.files || [],
entry.status,
originalFileName,
type === GitCommitType.Branch ? entry.parentShas![0] : undefined,
type === GitCommitType.Log ? entry.parentShas![0] : undefined,
undefined,
entry.parentShas!,
entry.line
@ -393,7 +393,7 @@ export class GitLogParser {
commit.nextSha = commit.sha !== recentCommit.sha ? recentCommit.sha : recentCommit.nextSha;
// Only add a filename if this is a file log
if (type === GitCommitType.File) {
if (type === GitCommitType.LogFile) {
recentCommit.previousFileName = commit.originalFileName || commit.fileName;
commit.nextFileName = recentCommit.originalFileName || recentCommit.fileName;
}

+ 1
- 1
src/hovers/lineHoverController.ts Переглянути файл

@ -99,7 +99,7 @@ export class LineHoverController implements Disposable {
// Get the full commit message -- since blame only returns the summary
let logCommit = lineState !== undefined ? lineState.logCommit : undefined;
if (logCommit === undefined && !commit.isUncommitted) {
logCommit = await Container.git.getLogCommitForFile(commit.repoPath, commit.uri.fsPath, {
logCommit = await Container.git.getCommitForFile(commit.repoPath, commit.uri.fsPath, {
ref: commit.sha
});
if (logCommit !== undefined) {

+ 1
- 1
src/quickpicks/commitFileQuickPick.ts Переглянути файл

@ -103,7 +103,7 @@ export class CommitFileQuickPick {
const isUncommitted = commit.isUncommitted;
if (isUncommitted) {
// Since we can't trust the previous sha on an uncommitted commit, find the last commit for this file
const c = await Container.git.getRecentLogCommitForFile(undefined, commit.uri.fsPath);
const c = await Container.git.getCommitForFile(undefined, commit.uri.fsPath);
if (c === undefined) return undefined;
commit = c;

+ 2
- 2
src/quickpicks/repoStatusQuickPick.ts Переглянути файл

@ -52,7 +52,7 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
this.status = status;
if (status.indexStatus !== undefined) {
this.commit = new GitLogCommit(
GitCommitType.File,
GitCommitType.LogFile,
status.repoPath,
GitService.stagedUncommittedSha,
'You',
@ -70,7 +70,7 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
}
else {
this.commit = new GitLogCommit(
GitCommitType.File,
GitCommitType.LogFile,
status.repoPath,
GitService.uncommittedSha,
'You',

+ 1
- 1
src/views/nodes/fileHistoryNode.ts Переглянути файл

@ -54,7 +54,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
const user = await Container.git.getCurrentUser(this.uri.repoPath!);
const commit = new GitLogCommit(
GitCommitType.File,
GitCommitType.LogFile,
this.uri.repoPath!,
sha,
'You',

+ 1
- 1
src/views/nodes/lineHistoryNode.ts Переглянути файл

@ -59,7 +59,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
};
const uncommitted = new GitLogCommit(
GitCommitType.File,
GitCommitType.LogFile,
this.uri.repoPath!,
commit.sha,
'You',

+ 1
- 1
src/views/nodes/statusFilesNode.ts Переглянути файл

@ -166,7 +166,7 @@ export class StatusFilesNode extends ViewNode {
fileName: file.fileName,
originalFileName: file.originalFileName,
commit: new GitLogCommit(
GitCommitType.File,
GitCommitType.LogFile,
file.repoPath,
ref,
'You',

+ 1
- 1
src/views/viewCommands.ts Переглянути файл

@ -367,7 +367,7 @@ export class ViewCommands implements Disposable {
};
if (node instanceof ResultsFileNode) {
args.commit = await Container.git.getLogCommitForFile(node.repoPath, node.uri.fsPath, {
args.commit = await Container.git.getCommitForFile(node.repoPath, node.uri.fsPath, {
ref: node.uri.sha,
firstIfNotFound: true,
reverse: true

Завантаження…
Відмінити
Зберегти