Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/github/createPRViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques

protected abstract detectBaseMetadata(defaultCompareBranch: Branch): Promise<BaseBranchMetadata | undefined>;

// Called once the detected base branch is known, before getTitleAndDescription runs.
// Subclasses can override to update model state that getTitleAndDescription depends on.
protected onBaseBranchDetected(_baseOwner: string, _baseBranch: string): void { }

protected getTitleAndDescriptionProvider(name?: string) {
return this._folderRepositoryManager.getTitleAndDescriptionProvider(name);
}
Expand All @@ -214,6 +218,9 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques

const defaultBaseBranch = detectedBaseMetadata?.branch ?? this._pullRequestDefaults.base;

// Notify subclasses so they can update model state before getTitleAndDescription runs.
this.onBaseBranchDetected(defaultBaseRemote.owner, defaultBaseBranch);

let defaultTitleAndDescription: { title: string; description: string };
let mergeConfiguration: RepoAccessAndMergeMethods | undefined;
let viewerPermission: ViewerPermission;
Expand Down Expand Up @@ -1022,10 +1029,13 @@ Don't forget to commit your template file to the repository so that it can be us
}
}

protected override onBaseBranchDetected(baseOwner: string, baseBranch: string): void {
this.model.baseOwner = baseOwner;
this.model.baseBranch = baseBranch;
}

protected override async getCreateParams(): Promise<CreateParamsNew> {
const params = await super.getCreateParams();
this.model.baseOwner = params.defaultBaseRemote!.owner;
this.model.baseBranch = params.defaultBaseBranch!;
// Pre-fetch branches so they're cached when the user opens the branch picker
this.prefetchBranches(params.defaultBaseRemote!);
return params;
Expand Down