mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Git - Migrate post commit command storage (#171416)
* Git - Migrate post commit command storage * Make it explicit that migration is async
This commit is contained in:
@@ -81,7 +81,7 @@ export class CommitCommandsCenter {
|
||||
return;
|
||||
}
|
||||
|
||||
this.globalState.update(this.repository.root, command)
|
||||
this.globalState.update(this.getGlobalStateKey(), command)
|
||||
.then(() => this._onDidChange.fire());
|
||||
}
|
||||
|
||||
@@ -92,20 +92,24 @@ export class CommitCommandsCenter {
|
||||
) {
|
||||
const root = Uri.file(repository.root);
|
||||
|
||||
const onRememberPostCommitCommandChange = async () => {
|
||||
const config = workspace.getConfiguration('git', root);
|
||||
if (!config.get<boolean>('rememberPostCommitCommand')) {
|
||||
await this.globalState.update(repository.root, undefined);
|
||||
}
|
||||
};
|
||||
this.disposables.push(workspace.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('git.rememberPostCommitCommand', root)) {
|
||||
// Migrate post commit command storage
|
||||
this.migratePostCommitCommandStorage()
|
||||
.then(() => {
|
||||
const onRememberPostCommitCommandChange = async () => {
|
||||
const config = workspace.getConfiguration('git', root);
|
||||
if (!config.get<boolean>('rememberPostCommitCommand')) {
|
||||
await this.globalState.update(this.getGlobalStateKey(), undefined);
|
||||
}
|
||||
};
|
||||
this.disposables.push(workspace.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('git.rememberPostCommitCommand', root)) {
|
||||
onRememberPostCommitCommandChange();
|
||||
}
|
||||
}));
|
||||
onRememberPostCommitCommandChange();
|
||||
}
|
||||
}));
|
||||
onRememberPostCommitCommandChange();
|
||||
|
||||
this.disposables.push(postCommitCommandsProviderRegistry.onDidChangePostCommitCommandsProviders(() => this._onDidChange.fire()));
|
||||
this.disposables.push(postCommitCommandsProviderRegistry.onDidChangePostCommitCommandsProviders(() => this._onDidChange.fire()));
|
||||
});
|
||||
}
|
||||
|
||||
getPrimaryCommand(): Command {
|
||||
@@ -155,12 +159,16 @@ export class CommitCommandsCenter {
|
||||
}
|
||||
finally {
|
||||
if (!this.isRememberPostCommitCommandEnabled()) {
|
||||
await this.globalState.update(this.repository.root, undefined);
|
||||
await this.globalState.update(this.getGlobalStateKey(), undefined);
|
||||
this._onDidChange.fire();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private getGlobalStateKey(): string {
|
||||
return `postCommitCommand:${this.repository.root}`;
|
||||
}
|
||||
|
||||
private getCommitCommand(): Command {
|
||||
const config = workspace.getConfiguration('git', Uri.file(this.repository.root));
|
||||
|
||||
@@ -199,7 +207,16 @@ export class CommitCommandsCenter {
|
||||
}
|
||||
|
||||
private getPostCommitCommandStringFromStorage(): string | null | undefined {
|
||||
return this.globalState.get<string | null>(this.repository.root);
|
||||
return this.globalState.get<string | null>(this.getGlobalStateKey());
|
||||
}
|
||||
|
||||
private async migratePostCommitCommandStorage(): Promise<void> {
|
||||
const postCommitCommandString = this.globalState.get<string | null>(this.repository.root);
|
||||
|
||||
if (postCommitCommandString !== undefined) {
|
||||
await this.globalState.update(this.getGlobalStateKey(), postCommitCommandString);
|
||||
await this.globalState.update(this.repository.root, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
private isRememberPostCommitCommandEnabled(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user