Skip to content

Commit 5c10ed4

Browse files
Copilotalexr00
andcommitted
Hard-code recently used branches limit to 10 and allow branches not in list
- Remove recentlyUsedBranchesCount setting as requested - Hard-code limit to 10 branches instead of using configurable setting - Allow recently used branches even if they're not in the fetched branch list This ensures branches like 'develop' are shown even when timeout cuts off the list Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 5766796 commit 5c10ed4

File tree

4 files changed

+7
-30
lines changed

4 files changed

+7
-30
lines changed

package.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,6 @@
198198
"minimum": 1000,
199199
"markdownDescription": "%githubPullRequests.branchListTimeout.description%"
200200
},
201-
"githubPullRequests.recentlyUsedBranchesCount": {
202-
"type": "number",
203-
"default": 5,
204-
"minimum": 0,
205-
"maximum": 20,
206-
"markdownDescription": "%githubPullRequests.recentlyUsedBranchesCount.description%"
207-
},
208201
"githubPullRequests.remotes": {
209202
"type": "array",
210203
"default": [

package.nls.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
]
2222
},
2323
"githubPullRequests.branchListTimeout.description": "Maximum time in milliseconds to wait when fetching the list of branches for pull request creation. Repositories with thousands of branches may need a higher value to ensure all branches (including the default branch) are retrieved. Minimum value is 1000 (1 second).",
24-
"githubPullRequests.recentlyUsedBranchesCount.description": "The maximum number of recently used base branches to track and show at the top of the branch picker when creating a pull request. Set to 0 to disable this feature.",
2524
"githubPullRequests.codingAgent.description": "Enables integration with the asynchronous Copilot coding agent. The '#copilotCodingAgent' tool will be available in agent mode when this setting is enabled.",
2625
"githubPullRequests.codingAgent.uiIntegration.description": "Enables UI integration within VS Code to create new coding agent sessions.",
2726
"githubPullRequests.codingAgent.autoCommitAndPush.description": "Allow automatic git operations (commit, push) to be performed when starting a coding agent session",

src/common/settingKeys.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const PR_SETTINGS_NAMESPACE = 'githubPullRequests';
77
export const TERMINAL_LINK_HANDLER = 'terminalLinksHandler';
88
export const BRANCH_PUBLISH = 'createOnPublishBranch';
99
export const BRANCH_LIST_TIMEOUT = 'branchListTimeout';
10-
export const RECENTLY_USED_BRANCHES_COUNT = 'recentlyUsedBranchesCount';
1110
export const USE_REVIEW_MODE = 'useReviewMode';
1211
export const FILE_LIST_LAYOUT = 'fileListLayout';
1312
export const HIDE_VIEWED_FILES = 'hideViewedFiles';

src/github/createPRViewProvider.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ import {
3434
PR_SETTINGS_NAMESPACE,
3535
PULL_REQUEST_DESCRIPTION,
3636
PULL_REQUEST_LABELS,
37-
PUSH_BRANCH,
38-
RECENTLY_USED_BRANCHES_COUNT
37+
PUSH_BRANCH
3938
} from '../common/settingKeys';
4039
import { ITelemetry } from '../common/telemetry';
4140
import { asPromise, compareIgnoreCase, formatError, promiseWithTimeout } from '../common/utils';
@@ -134,27 +133,13 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
134133
return repo.getRepoAccessAndMergeMethods(refetch);
135134
}
136135

137-
private getRecentlyUsedBranchesMaxCount(): number {
138-
return vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<number>(RECENTLY_USED_BRANCHES_COUNT, 5);
139-
}
140-
141136
protected getRecentlyUsedBranches(owner: string, repositoryName: string): string[] {
142-
const maxCount = this.getRecentlyUsedBranchesMaxCount();
143-
if (maxCount === 0) {
144-
return [];
145-
}
146-
147137
const repoKey = `${owner}/${repositoryName}`;
148138
const state = this._folderRepositoryManager.context.workspaceState.get<RecentlyUsedBranchesState>(RECENTLY_USED_BRANCHES, { branches: {} });
149139
return state.branches[repoKey] || [];
150140
}
151141

152142
protected saveRecentlyUsedBranch(owner: string, repositoryName: string, branchName: string): void {
153-
const maxCount = this.getRecentlyUsedBranchesMaxCount();
154-
if (maxCount === 0) {
155-
return;
156-
}
157-
158143
const repoKey = `${owner}/${repositoryName}`;
159144
const state = this._folderRepositoryManager.context.workspaceState.get<RecentlyUsedBranchesState>(RECENTLY_USED_BRANCHES, { branches: {} });
160145

@@ -167,8 +152,8 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
167152
// Add it to the front
168153
recentBranches.unshift(branchName);
169154

170-
// Limit to maxCount
171-
recentBranches = recentBranches.slice(0, maxCount);
155+
// Limit to 10 branches
156+
recentBranches = recentBranches.slice(0, 10);
172157

173158
// Save back to state
174159
state.branches[repoKey] = recentBranches;
@@ -871,9 +856,10 @@ export class CreatePullRequestViewProvider extends BaseCreatePullRequestViewProv
871856
let otherBranches: string[] = branchNames;
872857
if (isBase) {
873858
const recentlyUsed = this.getRecentlyUsedBranches(githubRepository.remote.owner, githubRepository.remote.repositoryName);
874-
// Filter to only include branches that exist in the current branch list
875-
recentBranches = recentlyUsed.filter(recent => branchNames.includes(recent));
876-
// Remove recently used branches from the main list
859+
// Include all recently used branches, even if they're not in the current branch list
860+
// This allows showing branches that weren't fetched due to timeout
861+
recentBranches = recentlyUsed;
862+
// Remove recently used branches from the main list (if they exist there)
877863
otherBranches = branchNames.filter(name => !recentBranches.includes(name));
878864
}
879865

0 commit comments

Comments
 (0)