Skip to content

Commit e0ebc5a

Browse files
Copilotalexr00
andcommitted
Add githubIssues.workingBaseBranch setting with implementation
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 3ed1fa4 commit e0ebc5a

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,21 @@
711711
"default": "on",
712712
"markdownDescription": "%githubIssues.useBranchForIssues.markdownDescription%"
713713
},
714+
"githubIssues.workingBaseBranch": {
715+
"type": "string",
716+
"enum": [
717+
"currentBranch",
718+
"defaultBranch",
719+
"prompt"
720+
],
721+
"enumDescriptions": [
722+
"%githubIssues.workingBaseBranch.currentBranch%",
723+
"%githubIssues.workingBaseBranch.defaultBranch%",
724+
"%githubIssues.workingBaseBranch.prompt%"
725+
],
726+
"default": "currentBranch",
727+
"markdownDescription": "%githubIssues.workingBaseBranch.markdownDescription%"
728+
},
714729
"githubIssues.issueCompletionFormatScm": {
715730
"type": "string",
716731
"default": "${issueTitle}\nFixes ${issueNumberLabel}",

package.nls.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@
130130
"githubIssues.useBranchForIssues.on": "A branch will always be checked out when you start working on an issue. If the branch doesn't exist, it will be created.",
131131
"githubIssues.useBranchForIssues.off": "A branch will not be created when you start working on an issue. If you have worked on an issue before and a branch was created for it, that same branch will be checked out.",
132132
"githubIssues.useBranchForIssues.prompt": "A prompt will show for setting the name of the branch that will be created and checked out.",
133+
"githubIssues.workingBaseBranch.markdownDescription": {
134+
"message": "Determines which branch to use as the base when creating a new branch for an issue. This setting controls what branch the new issue branch is created from.",
135+
"comment": [
136+
"Describes the base branch selection for issue branches"
137+
]
138+
},
139+
"githubIssues.workingBaseBranch.currentBranch": "Create the issue branch from the current branch without switching to the default branch first.",
140+
"githubIssues.workingBaseBranch.defaultBranch": "Always switch to the default branch before creating the issue branch.",
141+
"githubIssues.workingBaseBranch.prompt": "Prompt which branch to use as the base when creating an issue branch.",
133142
"githubIssues.issueCompletionFormatScm.markdownDescription": {
134143
"message": "Sets the format of issue completions in the SCM inputbox. \n- `${user}` will be replace with the currently logged in username \n- `${issueNumber}` will be replaced with the current issue number \n- `${issueNumberLabel}` will be replaced with a label formatted as #number or owner/repository#number, depending on whether the issue is in the current repository",
135144
"comment": [

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export const IGNORE_USER_COMPLETION_TRIGGER = 'ignoreUserCompletionTrigger';
4949
export const CREATE_INSERT_FORMAT = 'createInsertFormat';
5050
export const ISSUE_BRANCH_TITLE = 'issueBranchTitle';
5151
export const USE_BRANCH_FOR_ISSUES = 'useBranchForIssues';
52+
export const WORKING_BASE_BRANCH = 'workingBaseBranch';
5253
export const WORKING_ISSUE_FORMAT_SCM = 'workingIssueFormatScm';
5354
export const IGNORE_COMPLETION_TRIGGER = 'ignoreCompletionTrigger';
5455
export const ISSUE_COMPLETION_FORMAT_SCM = 'issueCompletionFormatScm';

src/issues/issueFeatureRegistrar.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ISSUE_COMPLETIONS,
2121
ISSUES_SETTINGS_NAMESPACE,
2222
USER_COMPLETIONS,
23+
WORKING_BASE_BRANCH,
2324
} from '../common/settingKeys';
2425
import { editQuery } from '../common/settingsUtils';
2526
import { ITelemetry } from '../common/telemetry';
@@ -824,10 +825,30 @@ export class IssueFeatureRegistrar extends Disposable {
824825
}
825826
}
826827

828+
// Determine whether to checkout the default branch based on workingBaseBranch setting
829+
const workingBaseBranchConfig = vscode.workspace.getConfiguration(ISSUES_SETTINGS_NAMESPACE).get<string>(WORKING_BASE_BRANCH);
830+
let checkoutDefaultBranch = false;
831+
832+
if (workingBaseBranchConfig === 'defaultBranch') {
833+
checkoutDefaultBranch = true;
834+
} else if (workingBaseBranchConfig === 'prompt') {
835+
const currentBranchOption = vscode.l10n.t('Current Branch');
836+
const defaultBranchOption = vscode.l10n.t('Default Branch');
837+
const choice = await vscode.window.showQuickPick([currentBranchOption, defaultBranchOption], {
838+
placeHolder: vscode.l10n.t('Which branch should be used as the base for the new issue branch?'),
839+
});
840+
if (choice === undefined) {
841+
// User cancelled the prompt
842+
return;
843+
}
844+
checkoutDefaultBranch = choice === defaultBranchOption;
845+
}
846+
// else workingBaseBranchConfig === 'currentBranch', checkoutDefaultBranch remains false
847+
827848
await this._stateManager.setCurrentIssue(
828849
repoManager,
829850
new CurrentIssue(issueModel, repoManager, this._stateManager, remoteNameResult.remote, needsBranchPrompt),
830-
true
851+
checkoutDefaultBranch
831852
);
832853
}
833854

0 commit comments

Comments
 (0)