diff --git a/package.json b/package.json index b4b768559d..db7041acb5 100644 --- a/package.json +++ b/package.json @@ -429,6 +429,11 @@ "default": false, "description": "%githubPullRequests.ignoreSubmodules.description%" }, + "githubPullRequests.allowReposOutsideWorkspace": { + "type": "boolean", + "default": false, + "description": "%githubPullRequests.allowReposOutsideWorkspace.description%" + }, "githubPullRequests.neverIgnoreDefaultBranch": { "type": "boolean", "description": "%githubPullRequests.neverIgnoreDefaultBranch.description%" diff --git a/package.nls.json b/package.nls.json index 17aeb3a2b5..ace91ed83e 100644 --- a/package.nls.json +++ b/package.nls.json @@ -70,6 +70,7 @@ "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.ignoreSubmodules.description": "Prevents repositories that are submodules from being managed by the GitHub Pull Requests extension. A window reload is required for changes to this setting to take effect.", + "githubPullRequests.allowReposOutsideWorkspace.description": "Allows repositories that are outside of the workspace folders to be managed by the GitHub Pull Requests extension. A window reload is required for changes to this setting to take effect.", "githubPullRequests.neverIgnoreDefaultBranch.description": "Never offer to ignore a pull request associated with the default branch of a repository.", "githubPullRequests.overrideDefaultBranch.description": "The default branch for a repository is set on github.com. With this setting, you can override that default with another branch.", "githubPullRequests.postCreate.description": "The action to take after creating a pull request.", diff --git a/src/common/settingKeys.ts b/src/common/settingKeys.ts index 1376c4c7bc..950c1ddb71 100644 --- a/src/common/settingKeys.ts +++ b/src/common/settingKeys.ts @@ -14,6 +14,7 @@ export const ASSIGN_TO = 'assignCreated'; export const PUSH_BRANCH = 'pushBranch'; export const IGNORE_PR_BRANCHES = 'ignoredPullRequestBranches'; export const IGNORE_SUBMODULES = 'ignoreSubmodules'; +export const ALLOW_REPOS_OUTSIDE_WORKSPACE = 'allowReposOutsideWorkspace'; export const NEVER_IGNORE_DEFAULT_BRANCH = 'neverIgnoreDefaultBranch'; export const OVERRIDE_DEFAULT_BRANCH = 'overrideDefaultBranch'; export const PULL_BRANCH = 'pullBranch'; diff --git a/src/extension.ts b/src/extension.ts index 78f8936cb0..465b27f6fb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -16,7 +16,7 @@ import { isSubmodule } from './common/gitUtils'; import Logger from './common/logger'; import * as PersistentState from './common/persistentState'; import { parseRepositoryRemotes } from './common/remote'; -import { BRANCH_PUBLISH, EXPERIMENTAL_CHAT, FILE_LIST_LAYOUT, GIT, IGNORE_SUBMODULES, OPEN_DIFF_ON_CLICK, PR_SETTINGS_NAMESPACE, SHOW_INLINE_OPEN_FILE_ACTION } from './common/settingKeys'; +import { ALLOW_REPOS_OUTSIDE_WORKSPACE, BRANCH_PUBLISH, EXPERIMENTAL_CHAT, FILE_LIST_LAYOUT, GIT, IGNORE_SUBMODULES, OPEN_DIFF_ON_CLICK, PR_SETTINGS_NAMESPACE, SHOW_INLINE_OPEN_FILE_ACTION } from './common/settingKeys'; import { initBasedOnSettingChange } from './common/settingsUtils'; import { TemporaryState } from './common/temporaryState'; import { Schemes } from './common/uri'; @@ -228,7 +228,8 @@ async function init( } // Check if repo is in one of the workspace folders or vice versa - if (workspaceFolders && !workspaceFolders.some(folder => isDescendant(folder.uri.fsPath, repo.rootUri.fsPath) || isDescendant(repo.rootUri.fsPath, folder.uri.fsPath))) { + const allowReposOutsideWorkspace = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get(ALLOW_REPOS_OUTSIDE_WORKSPACE, false); + if (!allowReposOutsideWorkspace && workspaceFolders && !workspaceFolders.some(folder => isDescendant(folder.uri.fsPath, repo.rootUri.fsPath) || isDescendant(repo.rootUri.fsPath, folder.uri.fsPath))) { Logger.appendLine(`Repo ${repo.rootUri} is not in a workspace folder, ignoring.`, ACTIVATION); return; }