Browse Source

Removes unneeded shortSha parameter

main
Eric Amodio 7 years ago
parent
commit
d420d82ab2
4 changed files with 11 additions and 11 deletions
  1. +6
    -3
      src/gitService.ts
  2. +3
    -6
      src/quickPicks/commitDetails.ts
  3. +1
    -1
      src/quickPicks/commitFileDetails.ts
  4. +1
    -1
      src/views/gitExplorer.ts

+ 6
- 3
src/gitService.ts View File

@ -1061,15 +1061,17 @@ export class GitService extends Disposable {
return Git.normalizePath(fileName, repoPath);
}
static shortenSha(sha: string) {
static shortenSha(sha: string | undefined) {
if (sha === undefined) return undefined;
return Git.shortenSha(sha);
}
static toGitContentUri(sha: string, shortSha: string, fileName: string, repoPath: string, originalFileName?: string): Uri;
static toGitContentUri(sha: string, fileName: string, repoPath: string, originalFileName?: string): Uri;
static toGitContentUri(commit: GitCommit): Uri;
static toGitContentUri(uri: GitUri): Uri;
static toGitContentUri(shaOrcommitOrUri: string | GitCommit | GitUri, shortSha?: string, fileName?: string, repoPath?: string, originalFileName?: string): Uri {
static toGitContentUri(shaOrcommitOrUri: string | GitCommit | GitUri, fileName?: string, repoPath?: string, originalFileName?: string): Uri {
let data: IGitUriData;
let shortSha: string | undefined;
if (typeof shaOrcommitOrUri === 'string') {
data = GitService._toGitUriData({
sha: shaOrcommitOrUri,
@ -1077,6 +1079,7 @@ export class GitService extends Disposable {
repoPath: repoPath!,
originalFileName: originalFileName
});
shortSha = GitService.shortenSha(shaOrcommitOrUri);
}
else if (shaOrcommitOrUri instanceof GitCommit) {
data = GitService._toGitUriData(shaOrcommitOrUri, undefined, shaOrcommitOrUri.originalFileName);

+ 3
- 6
src/quickPicks/commitDetails.ts View File

@ -24,17 +24,14 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
const description = GitStatusFile.getFormattedDirectory(status, true);
let sha;
let shortSha;
if (status.status === 'D') {
sha = commit.previousSha!;
shortSha = commit.previousShortSha!;
}
else {
sha = commit.sha;
shortSha = commit.shortSha;
}
super(GitService.toGitContentUri(sha, shortSha, status.fileName, commit.repoPath, status.originalFileName), {
super(GitService.toGitContentUri(sha, status.fileName, commit.repoPath, status.originalFileName), {
label: `${Strings.pad(octicon, 4, 2)} ${path.basename(status.fileName)}`,
description: description
});
@ -48,7 +45,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
originalFileName: status.originalFileName
} as IGitCommitInfo);
this.sha = sha;
this.shortSha = shortSha;
this.shortSha = GitService.shortenSha(sha)!;
this.status = status.status;
}
@ -88,7 +85,7 @@ export class OpenCommitFileRevisionsCommandQuickPickItem extends OpenFilesComman
constructor(commit: GitLogCommit, item?: QuickPickItem) {
const uris = commit.fileStatuses
.filter(s => s.status !== 'D')
.map(s => GitService.toGitContentUri(commit.sha, commit.shortSha, s.fileName, commit.repoPath, s.originalFileName));
.map(s => GitService.toGitContentUri(commit.sha, s.fileName, commit.repoPath, s.originalFileName));
super(uris, item || {
label: `$(file-symlink-file) Open Changed Revisions`,

+ 1
- 1
src/quickPicks/commitFileDetails.ts View File

@ -27,7 +27,7 @@ export class OpenCommitFileRevisionCommandQuickPickItem extends OpenFileCommandQ
let description: string;
let uri: Uri;
if (commit.status === 'D') {
uri = GitService.toGitContentUri(commit.previousSha!, commit.previousShortSha!, commit.previousFileName!, commit.repoPath, undefined);
uri = GitService.toGitContentUri(commit.previousSha!, commit.previousFileName!, commit.repoPath, undefined);
description = `${Strings.pad(GlyphChars.Dash, 2, 3)} ${path.basename(commit.fileName)} in ${GlyphChars.Space}$(git-commit) ${commit.previousShortSha} (deleted in ${GlyphChars.Space}$(git-commit) ${commit.shortSha})`;
}
else {

+ 1
- 1
src/views/gitExplorer.ts View File

@ -188,7 +188,7 @@ export class GitExplorer implements TreeDataProvider {
private async openChangedFileRevisions(node: CommitNode | StashNode, options: TextDocumentShowOptions = { preserveFocus: false, preview: false }) {
const uris = node.commit.fileStatuses
.filter(s => s.status !== 'D')
.map(s => GitService.toGitContentUri(node.commit.sha, node.commit.shortSha, s.fileName, node.commit.repoPath, s.originalFileName));
.map(s => GitService.toGitContentUri(node.commit.sha, s.fileName, node.commit.repoPath, s.originalFileName));
for (const uri of uris) {
await openEditor(uri, options);
}

Loading…
Cancel
Save