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); return Git.normalizePath(fileName, repoPath);
} }
static shortenSha(sha: string) {
static shortenSha(sha: string | undefined) {
if (sha === undefined) return undefined;
return Git.shortenSha(sha); 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(commit: GitCommit): Uri;
static toGitContentUri(uri: GitUri): 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 data: IGitUriData;
let shortSha: string | undefined;
if (typeof shaOrcommitOrUri === 'string') { if (typeof shaOrcommitOrUri === 'string') {
data = GitService._toGitUriData({ data = GitService._toGitUriData({
sha: shaOrcommitOrUri, sha: shaOrcommitOrUri,
@ -1077,6 +1079,7 @@ export class GitService extends Disposable {
repoPath: repoPath!, repoPath: repoPath!,
originalFileName: originalFileName originalFileName: originalFileName
}); });
shortSha = GitService.shortenSha(shaOrcommitOrUri);
} }
else if (shaOrcommitOrUri instanceof GitCommit) { else if (shaOrcommitOrUri instanceof GitCommit) {
data = GitService._toGitUriData(shaOrcommitOrUri, undefined, shaOrcommitOrUri.originalFileName); 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); const description = GitStatusFile.getFormattedDirectory(status, true);
let sha; let sha;
let shortSha;
if (status.status === 'D') { if (status.status === 'D') {
sha = commit.previousSha!; sha = commit.previousSha!;
shortSha = commit.previousShortSha!;
} }
else { else {
sha = commit.sha; 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)}`, label: `${Strings.pad(octicon, 4, 2)} ${path.basename(status.fileName)}`,
description: description description: description
}); });
@ -48,7 +45,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
originalFileName: status.originalFileName originalFileName: status.originalFileName
} as IGitCommitInfo); } as IGitCommitInfo);
this.sha = sha; this.sha = sha;
this.shortSha = shortSha;
this.shortSha = GitService.shortenSha(sha)!;
this.status = status.status; this.status = status.status;
} }
@ -88,7 +85,7 @@ export class OpenCommitFileRevisionsCommandQuickPickItem extends OpenFilesComman
constructor(commit: GitLogCommit, item?: QuickPickItem) { constructor(commit: GitLogCommit, item?: QuickPickItem) {
const uris = commit.fileStatuses const uris = commit.fileStatuses
.filter(s => s.status !== 'D') .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 || { super(uris, item || {
label: `$(file-symlink-file) Open Changed Revisions`, 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 description: string;
let uri: Uri; let uri: Uri;
if (commit.status === 'D') { 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})`; 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 { 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 }) { private async openChangedFileRevisions(node: CommitNode | StashNode, options: TextDocumentShowOptions = { preserveFocus: false, preview: false }) {
const uris = node.commit.fileStatuses const uris = node.commit.fileStatuses
.filter(s => s.status !== 'D') .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) { for (const uri of uris) {
await openEditor(uri, options); await openEditor(uri, options);
} }

Loading…
Cancel
Save