Skip to content

Commit 79c93f9

Browse files
authored
PR creation flow is not smooth anymore (#6432)
Fixes #6386
1 parent 5fe238a commit 79c93f9

5 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/common/executeCommands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export namespace contexts {
1818
export const RESOLVING_CONFLICTS = 'github:resolvingConflicts';
1919
export const PULL_REQUEST_DESCRIPTION_VISIBLE = 'github:pullRequestDescriptionVisible';
2020
export const ACTIVE_COMMENT_HAS_SUGGESTION = 'github:activeCommentHasSuggestion';
21+
export const CREATING = 'pr:creating';
2122
}
2223

2324
export namespace commands {

src/github/createPRViewProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
11741174

11751175
CreatePullRequestViewProvider.withProgress(() => {
11761176
return vscode.window.withProgress({ location: vscode.ProgressLocation.Notification }, async progress => {
1177-
commands.setContext('pr:creating', true);
1177+
commands.setContext(contexts.CREATING, true);
11781178
let totalIncrement = 0;
11791179
progress.report({ message: vscode.l10n.t('Checking for upstream branch'), increment: totalIncrement });
11801180
let createdPR: PullRequestModel | undefined = undefined;
@@ -1260,7 +1260,7 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
12601260
vscode.window.showErrorMessage(vscode.l10n.t('There was an error creating the pull request: {0}', (e as Error).message));
12611261
}
12621262
} finally {
1263-
commands.setContext('pr:creating', false);
1263+
commands.setContext(contexts.CREATING, false);
12641264

12651265
let completeMessage: string;
12661266
if (createdPR) {

src/github/revertPRViewProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import * as vscode from 'vscode';
77
import { CreateParamsNew, CreatePullRequestNew } from '../../common/views';
88
import { openDescription } from '../commands';
9-
import { commands } from '../common/executeCommands';
9+
import { commands, contexts } from '../common/executeCommands';
1010
import { ITelemetry } from '../common/telemetry';
1111
import { IRequestMessage } from '../common/webview';
1212
import { BaseCreatePullRequestViewProvider, BasePullRequestDataModel } from './createPRViewProvider';
@@ -78,7 +78,7 @@ export class RevertPullRequestViewProvider extends BaseCreatePullRequestViewProv
7878
protected async create(message: IRequestMessage<CreatePullRequestNew>): Promise<void> {
7979
let revertPr: PullRequestModel | undefined;
8080
RevertPullRequestViewProvider.withProgress(async () => {
81-
commands.setContext('pr:creating', true);
81+
commands.setContext(contexts.CREATING, true);
8282
try {
8383
revertPr = await this._folderRepositoryManager.revert(this.pullRequest, message.args.title, message.args.body, message.args.draft);
8484
if (revertPr) {
@@ -102,7 +102,7 @@ export class RevertPullRequestViewProvider extends BaseCreatePullRequestViewProv
102102
vscode.window.showErrorMessage(vscode.l10n.t('There was an error creating the pull request: {0}', (e as Error).message));
103103
}
104104
} finally {
105-
commands.setContext('pr:creating', false);
105+
commands.setContext(contexts.CREATING, false);
106106
if (revertPr) {
107107
this._onDone.fire(revertPr);
108108
} else {

src/view/createPullRequestHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import * as vscode from 'vscode';
77
import { Repository } from '../api/api';
8+
import { commands } from '../common/executeCommands';
89
import { ITelemetry } from '../common/telemetry';
910
import { dispose } from '../common/utils';
1011
import { BaseCreatePullRequestViewProvider, BasePullRequestDataModel, CreatePullRequestViewProvider } from '../github/createPRViewProvider';
@@ -25,14 +26,13 @@ export class CreatePullRequestHelper implements vscode.Disposable {
2526

2627
private async setActiveContext(value: boolean) {
2728
if (this._activeContext) {
28-
await vscode.commands.executeCommand('setContext', this._activeContext, value);
29+
await commands.setContext(this._activeContext, value);
2930
}
3031
}
3132

3233
private registerListeners(repository: Repository, usingCurrentBranchAsCompare: boolean) {
3334
this._disposables.push(
3435
this._createPRViewProvider!.onDone(async createdPR => {
35-
this.setActiveContext(false);
3636
await CreatePullRequestViewProvider.withProgress(async () => {
3737
return this._postCreateCallback?.(createdPR);
3838
});

src/view/reviewManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ export class ReviewManager {
12941294
if (postCreate === 'checkoutDefaultBranch') {
12951295
await this._folderRepoManager.checkoutDefaultBranch(defaultBranch);
12961296
} if (postCreate === 'checkoutDefaultBranchAndShow') {
1297-
await vscode.commands.executeCommand('pr:github.focus');
1297+
await commands.executeCommand('pr:github.focus');
12981298
await this._folderRepoManager.checkoutDefaultBranch(defaultBranch);
12991299
await this._pullRequestsTree.expandPullRequest(createdPR);
13001300
} else if (postCreate === 'checkoutDefaultBranchAndCopy') {

0 commit comments

Comments
 (0)