Skip to content

Commit 4a1bfc7

Browse files
committed
Allows timeline to work with non-open repos
1 parent 31df505 commit 4a1bfc7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/webviews/plus/timeline/timelineWebview.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
604604
const dateFormat = configuration.get('defaultDateFormat') ?? 'MMMM Do, YYYY h:mma';
605605
const shortDateFormat = configuration.get('defaultDateShortFormat') ?? 'short';
606606

607+
const { git } = this.container;
607608
const { scope } = context;
608609

609610
const config: State['config'] = {
@@ -613,12 +614,15 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
613614
shortDateFormat: shortDateFormat,
614615
};
615616

616-
if (this.container.git.isDiscoveringRepositories) {
617-
await this.container.git.isDiscoveringRepositories;
617+
if (git.isDiscoveringRepositories) {
618+
await git.isDiscoveringRepositories;
618619
}
619620

620-
const repo = scope?.uri != null ? this.container.git.getRepository(scope?.uri) : undefined;
621-
const access = await this.container.git.access('timeline', repo?.uri);
621+
const repo =
622+
scope?.uri != null
623+
? git.getRepository(scope.uri) ?? (await git.getOrOpenRepository(scope.uri, { closeOnOpen: true }))
624+
: undefined;
625+
const access = await git.access('timeline', repo?.uri);
622626

623627
if (scope == null || repo == null) {
624628
return {
@@ -632,7 +636,7 @@ export class TimelineWebviewProvider implements WebviewProvider<State, State, Ti
632636
}
633637

634638
const { uri } = scope;
635-
const relativePath = this.container.git.getRelativePath(uri, repo.uri);
639+
const relativePath = git.getRelativePath(uri, repo.uri);
636640
const ref = getReference(await repo.git.branches().getBranch());
637641
const repository: State['repository'] =
638642
repo != null

0 commit comments

Comments
 (0)