Git - fix stage/unstage selected ranges in nested git repositories (#191987)

* Git - fix stage/unstage selected ranges in nested git repositories

* Remove the submodule check as it is being covered by the repository check

* Pull request feedback
This commit is contained in:
Ladislau Szomoru
2023-09-06 14:35:55 +02:00
committed by GitHub
parent 1f40d64450
commit a4e1870896
2 changed files with 16 additions and 7 deletions

View File

@@ -633,6 +633,14 @@ interface BranchProtectionMatcher {
exclude?: picomatch.Matcher;
}
export interface IRepositoryResolver {
getRepository(sourceControl: SourceControl): Repository | undefined;
getRepository(resourceGroup: SourceControlResourceGroup): Repository | undefined;
getRepository(path: string): Repository | undefined;
getRepository(resource: Uri): Repository | undefined;
getRepository(hint: any): Repository | undefined;
}
export class Repository implements Disposable {
private _onDidChangeRepository = new EventEmitter<Uri>();
@@ -784,6 +792,7 @@ export class Repository implements Disposable {
constructor(
private readonly repository: BaseRepository,
private readonly repositoryResolver: IRepositoryResolver,
private pushErrorHandlerRegistry: IPushErrorHandlerRegistry,
remoteSourcePublisherRegistry: IRemoteSourcePublisherRegistry,
postCommitCommandsProviderRegistry: IPostCommitCommandsProviderRegistry,
@@ -1010,13 +1019,13 @@ export class Repository implements Disposable {
return;
}
// Ignore path that is inside a merge group
if (this.mergeGroup.resourceStates.some(r => r.resourceUri.path === uri.path)) {
// Ignore path that is not inside the current repository
if (this.repositoryResolver.getRepository(uri) !== this) {
return undefined;
}
// Ignore path that is inside a submodule
if (this.submodules.some(s => isDescendant(path.join(this.repository.root, s.path), uri.path))) {
// Ignore path that is inside a merge group
if (this.mergeGroup.resourceStates.some(r => r.resourceUri.path === uri.path)) {
return undefined;
}