No way to `remove` or `rename` remote `upstream`

Fixes #4209
This commit is contained in:
Alex Ross 2023-07-21 17:34:33 +02:00
Родитель 1f33aa1f72
Коммит f3f523d16f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 89DDDBA66CBA7840
4 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -358,6 +358,19 @@
"description": "%githubPullRequests.experimental.createView.description%",
"default": true
},
"githubPullRequests.upstreamRemote": {
"type": "string",
"enum": [
"add",
"never"
],
"markdownDescription": "%githubPullRequests.upstreamRemote.description%",
"markdownEnumDescriptions": [
"%githubPullRequests.upstreamRemote.add%",
"%githubPullRequests.upstreamRemote.never%"
],
"default": "add"
},
"githubIssues.ignoreMilestones": {
"type": "array",
"default": [],

Просмотреть файл

@ -64,6 +64,9 @@
"githubPullRequests.defaultCommentType.review": "Submits the comment as a review comment that will be visible to other users once the review is submitted",
"githubPullRequests.setAutoMerge.description": "Checks the \"Auto-merge\" checkbox in the \"Create Pull Request\" view.",
"githubPullRequests.pullPullRequestBranchBeforeCheckout.description": "Pulls pull request before checkout",
"githubPullRequests.upstreamRemote.description": "Controls whether an `upstream` remote is automatically added for forks",
"githubPullRequests.upstreamRemote.add": "An `upstream` remote will be automatically added for forks",
"githubPullRequests.upstreamRemote.never": "An `upstream` remote will never be automatically added for forks",
"githubIssues.ignoreMilestones.description": "An array of milestones titles to never show issues from.",
"githubIssues.createIssueTriggers.description": "Strings that will cause the 'Create issue from comment' code action to show.",
"githubIssues.createIssueTriggers.items": "String that enables the 'Create issue from comment' code action. Should not contain whitespace.",

Просмотреть файл

@ -30,6 +30,7 @@ export const REMOTES = 'remotes';
export const PULL_PR_BRANCH_BEFORE_CHECKOUT = 'pullPullRequestBranchBeforeCheckout';
export const EXPERIMENTAL_ACCOUNT_BADGE = 'experimental.accountBadge';
export const EXPERIMENTAL_CREATE_VIEW = 'experimental.createView';
export const UPSTREAM_REMOTE = 'upstreamRemote';
export const ISSUES_SETTINGS_NAMESPACE = 'githubIssues';
export const ASSIGN_WHEN_WORKING = 'assignWhenWorking';

Просмотреть файл

@ -22,6 +22,7 @@ import {
PULL_BEFORE_CHECKOUT,
PULL_BRANCH,
REMOTES,
UPSTREAM_REMOTE,
} from '../common/settingKeys';
import { ITelemetry } from '../common/telemetry';
import { EventType, TimelineEvent } from '../common/timelineEvent';
@ -138,6 +139,7 @@ export class FolderRepositoryManager implements vscode.Disposable {
private _gitBlameCache: { [key: string]: string } = {};
private _githubManager: GitHubManager;
private _repositoryPageInformation: Map<string, PageInformation> = new Map<string, PageInformation>();
private _addedUpstreamCount: number = 0;
private _onDidMergePullRequest = new vscode.EventEmitter<void>();
readonly onDidMergePullRequest = this._onDidMergePullRequest.event;
@ -687,7 +689,8 @@ export class FolderRepositoryManager implements vscode.Disposable {
try {
const origin = await this.getOrigin();
const metadata = await origin.getMetadata();
if (metadata.fork && metadata.parent) {
const configuration = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE);
if (metadata.fork && metadata.parent && (configuration.get<'add' | 'never'>(UPSTREAM_REMOTE, 'add') === 'add')) {
const parentUrl = new Protocol(metadata.parent.git_url);
const missingParentRemote = !this._githubRepositories.some(
repo =>
@ -706,6 +709,17 @@ export class FolderRepositoryManager implements vscode.Disposable {
} else {
await this.repository.addRemote(remoteName, metadata.parent.clone_url);
}
this._addedUpstreamCount++;
if (this._addedUpstreamCount > 1) {
// We've already added this remote, which means the user likely removed it. Let the user know they can disable this feature.
const neverOption = vscode.l10n.t('Set to `never`');
vscode.window.showInformationMessage(vscode.l10n.t('An `upstream` remote has been added for this repository. You can disable this feature by setting `githubPullRequests.upstreamRemote` to `never`.'), neverOption)
.then(choice => {
if (choice === neverOption) {
configuration.update(UPSTREAM_REMOTE, 'never', vscode.ConfigurationTarget.Global);
}
});
}
return true;
}
}