Skip to content

Commit

Permalink
Add a setting that prevents fetch unless needed for new branch (#5449)
Browse files Browse the repository at this point in the history
Fixes #5439
  • Loading branch information
alexr00 authored Nov 7, 2023
1 parent cf4fa53 commit 21b8d73
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@
],
"description": "%githubPullRequests.pullBranch.description%"
},
"githubPullRequests.allowFetch": {
"type": "boolean",
"default": true,
"description": "%githubPullRequests.allowFetch.description%"
},
"githubPullRequests.ignoredPullRequestBranches": {
"type": "array",
"default": [],
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"githubPullRequests.pullBranch.prompt": "Prompt to pull a PR branch when changes are detected in the PR.",
"githubPullRequests.pullBranch.never": "Never pull a PR branch when changes are detected in the PR.",
"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.",
"githubPullRequests.allowFetch.description": "Allows `git fetch` to be run for checked-out pull request branches when checking for updates to the pull request.",
"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.",
"githubPullRequests.ignoredPullRequestBranches.items": "Branch name",
"githubPullRequests.neverIgnoreDefaultBranch.description": "Never offer to ignore a pull request associated with the default branch of a repository.",
Expand Down
1 change: 1 addition & 0 deletions src/common/settingKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const ISSUE_COMPLETION_FORMAT_SCM = 'issueCompletionFormatScm';
export const CREATE_ISSUE_TRIGGERS = 'createIssueTriggers';
export const DEFAULT = 'default';
export const IGNORE_MILESTONES = 'ignoreMilestones';
export const ALLOW_FETCH = 'allowFetch';

// git
export const GIT = 'git';
Expand Down
3 changes: 2 additions & 1 deletion src/github/folderRepositoryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Logger from '../common/logger';
import { Protocol, ProtocolType } from '../common/protocol';
import { GitHubRemote, parseRemote, parseRepositoryRemotes, Remote } from '../common/remote';
import {
ALLOW_FETCH,
AUTO_STASH,
DEFAULT_MERGE_METHOD,
GIT,
Expand Down Expand Up @@ -2219,7 +2220,7 @@ export class FolderRepositoryManager implements vscode.Disposable {
const remoteBranch = branch.upstream ? branch.upstream.name : branch.name;
if (remote) {
try {
if (shouldFetch) {
if (shouldFetch && vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<boolean>(ALLOW_FETCH, true)) {
await this._repository.fetch(remote, remoteBranch);
}
} catch (e) {
Expand Down

0 comments on commit 21b8d73

Please sign in to comment.