mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
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:
parent
1f40d64450
commit
a4e1870896
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { workspace, WorkspaceFoldersChangeEvent, Uri, window, Event, EventEmitter, QuickPickItem, Disposable, SourceControl, SourceControlResourceGroup, TextEditor, Memento, commands, LogOutputChannel, l10n, ProgressLocation, WorkspaceFolder } from 'vscode';
|
||||
import TelemetryReporter from '@vscode/extension-telemetry';
|
||||
import { Repository, RepositoryState } from './repository';
|
||||
import { IRepositoryResolver, Repository, RepositoryState } from './repository';
|
||||
import { memoize, sequentialize, debounce } from './decorators';
|
||||
import { dispose, anyEvent, filterEvent, isDescendant, pathEquals, toDisposable, eventToPromise } from './util';
|
||||
import { Git } from './git';
|
||||
|
@ -170,7 +170,7 @@ class UnsafeRepositoriesManager {
|
|||
}
|
||||
}
|
||||
|
||||
export class Model implements IBranchProtectionProviderRegistry, IRemoteSourcePublisherRegistry, IPostCommitCommandsProviderRegistry, IPushErrorHandlerRegistry {
|
||||
export class Model implements IRepositoryResolver, IBranchProtectionProviderRegistry, IRemoteSourcePublisherRegistry, IPostCommitCommandsProviderRegistry, IPushErrorHandlerRegistry {
|
||||
|
||||
private _onDidOpenRepository = new EventEmitter<Repository>();
|
||||
readonly onDidOpenRepository: Event<Repository> = this._onDidOpenRepository.event;
|
||||
|
@ -578,7 +578,7 @@ export class Model implements IBranchProtectionProviderRegistry, IRemoteSourcePu
|
|||
|
||||
// Open repository
|
||||
const [dotGit, repositoryRootRealPath] = await Promise.all([this.git.getRepositoryDotGit(repositoryRoot), this.getRepositoryRootRealPath(repositoryRoot)]);
|
||||
const repository = new Repository(this.git.open(repositoryRoot, repositoryRootRealPath, dotGit, this.logger), this, this, this, this, this.globalState, this.logger, this.telemetryReporter);
|
||||
const repository = new Repository(this.git.open(repositoryRoot, repositoryRootRealPath, dotGit, this.logger), this, this, this, this, this, this.globalState, this.logger, this.telemetryReporter);
|
||||
|
||||
this.open(repository);
|
||||
this._closedRepositoriesManager.deleteRepository(repository.root);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue