Skip to content

Commit 21b8d73

Browse files
authored
Add a setting that prevents fetch unless needed for new branch (#5449)
Fixes #5439
1 parent cf4fa53 commit 21b8d73

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@
320320
],
321321
"description": "%githubPullRequests.pullBranch.description%"
322322
},
323+
"githubPullRequests.allowFetch": {
324+
"type": "boolean",
325+
"default": true,
326+
"description": "%githubPullRequests.allowFetch.description%"
327+
},
323328
"githubPullRequests.ignoredPullRequestBranches": {
324329
"type": "array",
325330
"default": [],

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"githubPullRequests.pullBranch.prompt": "Prompt to pull a PR branch when changes are detected in the PR.",
6060
"githubPullRequests.pullBranch.never": "Never pull a PR branch when changes are detected in the PR.",
6161
"githubPullRequests.pullBranch.always": "Always pull a PR branch when changes are detected in the PR. When `\"git.autoStash\": true` this will instead `prompt` to prevent unexpected file changes.",
62+
"githubPullRequests.allowFetch.description": "Allows `git fetch` to be run for checked-out pull request branches when checking for updates to the pull request.",
6263
"githubPullRequests.ignoredPullRequestBranches.description": "Prevents branches that are associated with a pull request from being automatically detected. This will prevent review mode from being entered on these branches.",
6364
"githubPullRequests.ignoredPullRequestBranches.items": "Branch name",
6465
"githubPullRequests.neverIgnoreDefaultBranch.description": "Never offer to ignore a pull request associated with the default branch of a repository.",

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const ISSUE_COMPLETION_FORMAT_SCM = 'issueCompletionFormatScm';
4747
export const CREATE_ISSUE_TRIGGERS = 'createIssueTriggers';
4848
export const DEFAULT = 'default';
4949
export const IGNORE_MILESTONES = 'ignoreMilestones';
50+
export const ALLOW_FETCH = 'allowFetch';
5051

5152
// git
5253
export const GIT = 'git';

src/github/folderRepositoryManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Logger from '../common/logger';
1414
import { Protocol, ProtocolType } from '../common/protocol';
1515
import { GitHubRemote, parseRemote, parseRepositoryRemotes, Remote } from '../common/remote';
1616
import {
17+
ALLOW_FETCH,
1718
AUTO_STASH,
1819
DEFAULT_MERGE_METHOD,
1920
GIT,
@@ -2219,7 +2220,7 @@ export class FolderRepositoryManager implements vscode.Disposable {
22192220
const remoteBranch = branch.upstream ? branch.upstream.name : branch.name;
22202221
if (remote) {
22212222
try {
2222-
if (shouldFetch) {
2223+
if (shouldFetch && vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<boolean>(ALLOW_FETCH, true)) {
22232224
await this._repository.fetch(remote, remoteBranch);
22242225
}
22252226
} catch (e) {

0 commit comments

Comments
 (0)