Browse Source

Protects file/line history from bad URIs

main
Eric Amodio 1 year ago
parent
commit
194bfc3053
4 changed files with 11 additions and 9 deletions
  1. +4
    -3
      src/views/nodes/fileHistoryNode.ts
  2. +1
    -1
      src/views/nodes/fileHistoryTrackerNode.ts
  3. +5
    -4
      src/views/nodes/lineHistoryNode.ts
  4. +1
    -1
      src/views/nodes/lineHistoryTrackerNode.ts

+ 4
- 3
src/views/nodes/fileHistoryNode.ts View File

@ -54,19 +54,20 @@ export class FileHistoryNode extends SubscribeableViewNode impl
}`;
const children: ViewNode[] = [];
if (this.uri.repoPath == null) return children;
const range = this.branch != null ? await this.view.container.git.getBranchAheadRange(this.branch) : undefined;
const [log, fileStatuses, currentUser, getBranchAndTagTips, unpublishedCommits] = await Promise.all([
this.getLog(),
this.uri.sha == null
? this.view.container.git.getStatusForFiles(this.uri.repoPath!, this.getPathOrGlob())
? this.view.container.git.getStatusForFiles(this.uri.repoPath, this.getPathOrGlob())
: undefined,
this.uri.sha == null ? this.view.container.git.getCurrentUser(this.uri.repoPath!) : undefined,
this.uri.sha == null ? this.view.container.git.getCurrentUser(this.uri.repoPath) : undefined,
this.branch != null
? this.view.container.git.getBranchesAndTagsTipsFn(this.uri.repoPath, this.branch.name)
: undefined,
range
? this.view.container.git.getLogRefsOnly(this.uri.repoPath!, {
? this.view.container.git.getLogRefsOnly(this.uri.repoPath, {
limit: 0,
ref: range,
})

+ 1
- 1
src/views/nodes/fileHistoryTrackerNode.ts View File

@ -99,7 +99,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
}
get hasUri(): boolean {
return this._uri != unknownGitUri;
return this._uri != unknownGitUri && this._uri.repoPath != null;
}
@gate()

+ 5
- 4
src/views/nodes/lineHistoryNode.ts View File

@ -61,6 +61,7 @@ export class LineHistoryNode
}`;
const children: ViewNode[] = [];
if (this.uri.repoPath == null) return children;
let selection = this.selection;
@ -76,7 +77,7 @@ export class LineHistoryNode
? this.view.container.git.getBranchesAndTagsTipsFn(this.uri.repoPath, this.branch.name)
: undefined,
range
? this.view.container.git.getLogRefsOnly(this.uri.repoPath!, {
? this.view.container.git.getLogRefsOnly(this.uri.repoPath, {
limit: 0,
ref: range,
})
@ -100,7 +101,7 @@ export class LineHistoryNode
selection.active.character,
);
const status = await this.view.container.git.getStatusForFile(this.uri.repoPath!, this.uri);
const status = await this.view.container.git.getStatusForFile(this.uri.repoPath, this.uri);
if (status != null) {
const file: GitFile = {
@ -108,12 +109,12 @@ export class LineHistoryNode
path: commit.file?.path ?? '',
indexStatus: status?.indexStatus,
originalPath: commit.file?.originalPath,
repoPath: this.uri.repoPath!,
repoPath: this.uri.repoPath,
status: status?.status ?? GitFileIndexStatus.Modified,
workingTreeStatus: status?.workingTreeStatus,
};
const currentUser = await this.view.container.git.getCurrentUser(this.uri.repoPath!);
const currentUser = await this.view.container.git.getCurrentUser(this.uri.repoPath);
const pseudoCommits = status?.getPseudoCommits(this.view.container, currentUser);
if (pseudoCommits != null) {
for (const commit of pseudoCommits.reverse()) {

+ 1
- 1
src/views/nodes/lineHistoryTrackerNode.ts View File

@ -106,7 +106,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
}
get hasUri(): boolean {
return this._uri != unknownGitUri;
return this._uri != unknownGitUri && this._uri.repoPath != null;
}
@gate()

Loading…
Cancel
Save