Browse Source

Fixes #863 - tells built-in git about found repos

main
Eric Amodio 3 years ago
parent
commit
1d7be10b2a
6 changed files with 21 additions and 13 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      src/@types/git.d.ts
  3. +1
    -1
      src/commands/git/coauthors.ts
  4. +1
    -1
      src/commands/quickCommand.steps.ts
  5. +14
    -8
      src/git/gitService.ts
  6. +3
    -3
      src/git/models/repository.ts

+ 1
- 0
CHANGELOG.md View File

@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes [#863](https://github.com/eamodio/vscode-gitlens/issues/863) - Pulling all repositories doesn't work unless built-in Git knows about the repo (requires VS Code v1.53 or later)
- Fixes [#1332](https://github.com/eamodio/vscode-gitlens/issues/1332) - Stashes created with command line don't show up in the "Stashes" section
- Fixes [#1045](https://github.com/eamodio/vscode-gitlens/issues/1045) - View File History not working - absolute path used — thanks to [PR #1334](https://github.com/eamodio/vscode-gitlens/pull/1334) by egfx-notifications ([@egfx-notifications](https://github.com/egfx-notifications))
- Fixes [#1323](https://github.com/eamodio/vscode-gitlens/issues/1323) - Interactive rebase hangs

+ 1
- 0
src/@types/git.d.ts View File

@ -241,6 +241,7 @@ export interface API {
toGitUri(uri: Uri, ref: string): Uri;
getRepository(uri: Uri): Repository | null;
init(root: Uri): Promise<Repository | null>;
openRepository?(root: Uri): Promise<Repository | null>
registerRemoteSourceProvider(provider: RemoteSourceProvider): Disposable;
registerCredentialsProvider(provider: CredentialsProvider): Disposable;

+ 1
- 1
src/commands/git/coauthors.ts View File

@ -60,7 +60,7 @@ export class CoAuthorsGitCommand extends QuickCommand {
}
async execute(state: CoAuthorStepState) {
const repo = await GitService.getBuiltInGitRepository(state.repo.path);
const repo = await GitService.getOrOpenBuiltInGitRepository(state.repo.path);
if (repo == null) return;
let message = repo.inputBox.value;

+ 1
- 1
src/commands/quickCommand.steps.ts View File

@ -1017,7 +1017,7 @@ export async function* pickContributorsStep<
context: Context,
placeholder: string = 'Choose contributors',
): AsyncStepResultGenerator<GitContributor[]> {
const message = (await GitService.getBuiltInGitRepository(state.repo.path))?.inputBox.value;
const message = (await GitService.getOrOpenBuiltInGitRepository(state.repo.path))?.inputBox.value;
const step = QuickCommand.createPickStep<ContributorQuickPickItem>({
title: appendReposToTitle(context.title, state, context),

+ 14
- 8
src/git/gitService.ts View File

@ -291,6 +291,8 @@ export class GitService implements Disposable {
if (!this._repositoryTree.has(r.path)) {
this._repositoryTree.set(r.path, r);
}
void GitService.openBuiltInGitRepository(r.path);
}
}
}
@ -520,6 +522,8 @@ export class GitService implements Disposable {
if (!this._repositoryTree.has(r.path)) {
this._repositoryTree.set(r.path, r);
}
void GitService.openBuiltInGitRepository(r.path);
}
await this.updateContext(this._repositoryTree);
@ -4006,17 +4010,19 @@ export class GitService implements Disposable {
}
@log()
static async getBuiltInGitRepository(repoPath: string): Promise<BuiltInGitRepository | undefined> {
static async getOrOpenBuiltInGitRepository(repoPath: string): Promise<BuiltInGitRepository | undefined> {
const gitApi = await GitService.getBuiltInGitApi();
if (gitApi == null) return undefined;
const normalizedPath = Strings.normalizePath(repoPath, { stripTrailingSlash: true }).toLowerCase();
if (gitApi?.openRepository != null) {
return (await gitApi?.openRepository?.(Uri.file(repoPath))) ?? undefined;
}
const repo = gitApi.repositories.find(
r => Strings.normalizePath(r.rootUri.fsPath, { stripTrailingSlash: true }).toLowerCase() === normalizedPath,
);
return gitApi?.getRepository(Uri.file(repoPath)) ?? undefined;
}
return repo;
@log()
static async openBuiltInGitRepository(repoPath: string): Promise<BuiltInGitRepository | undefined> {
const gitApi = await GitService.getBuiltInGitApi();
return (await gitApi?.openRepository?.(Uri.file(repoPath))) ?? undefined;
}
static getEncoding(repoPath: string, fileName: string): string;

+ 3
- 3
src/git/models/repository.ts View File

@ -733,7 +733,7 @@ export class Repository implements Disposable {
) {
try {
if (GitReference.isBranch(options.reference)) {
const repo = await GitService.getBuiltInGitRepository(this.path);
const repo = await GitService.getOrOpenBuiltInGitRepository(this.path);
if (repo == null) return;
if (options.publish != null) {
@ -750,7 +750,7 @@ export class Repository implements Disposable {
}
}
} else if (options.reference != null) {
const repo = await GitService.getBuiltInGitRepository(this.path);
const repo = await GitService.getOrOpenBuiltInGitRepository(this.path);
if (repo == null) return;
const branch = await this.getBranch();
@ -1053,7 +1053,7 @@ export class Repository implements Disposable {
}
private async tryWatchingForChangesViaBuiltInApi() {
const repo = await GitService.getBuiltInGitRepository(this.path);
const repo = await GitService.getOrOpenBuiltInGitRepository(this.path);
if (repo != null) {
const internalRepo = (repo as any)._repository;
if (internalRepo != null && 'onDidChangeRepository' in internalRepo) {

Loading…
Cancel
Save