mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Share > Copy vscode.dev Link polish (#186576)
* Prompt when copying link and behind remote * Make dialog actions explicit re: copy behavior
This commit is contained in:
parent
bce3304e98
commit
52b72a22f9
|
@ -195,7 +195,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
|
|||
// If HEAD is not published, make sure it is
|
||||
&& !repository?.state.HEAD?.upstream
|
||||
) {
|
||||
const publishBranch = vscode.l10n.t('Publish Branch');
|
||||
const publishBranch = vscode.l10n.t('Publish Branch & Copy Link');
|
||||
const selection = await vscode.window.showInformationMessage(
|
||||
vscode.l10n.t('The current branch is not published to the remote. Would you like to publish your branch before copying a link?'),
|
||||
{ modal: true },
|
||||
|
@ -209,7 +209,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
|
|||
}
|
||||
|
||||
const uncommittedChanges = [...repository.state.workingTreeChanges, ...repository.state.indexChanges];
|
||||
if (uncommittedChanges.find((c) => c.uri.toString() === file.toString())) {
|
||||
if (uncommittedChanges.find((c) => c.uri.toString() === file.toString()) && !repository.state.HEAD?.ahead && !repository.state.HEAD?.behind) {
|
||||
const commitChanges = vscode.l10n.t('Commit Changes');
|
||||
const copyAnyway = vscode.l10n.t('Copy Anyway');
|
||||
const selection = await vscode.window.showWarningMessage(
|
||||
|
@ -225,7 +225,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
|
|||
throw new vscode.CancellationError();
|
||||
}
|
||||
} else if (repository.state.HEAD?.ahead) {
|
||||
const pushCommits = vscode.l10n.t('Push Commits');
|
||||
const pushCommits = vscode.l10n.t('Push Commits & Copy Link');
|
||||
const selection = await vscode.window.showInformationMessage(
|
||||
vscode.l10n.t('The current branch has unpublished commits. Would you like to push your commits before copying a link?'),
|
||||
{ modal: true },
|
||||
|
@ -236,6 +236,18 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
|
|||
}
|
||||
|
||||
await repository.push();
|
||||
} else if (repository.state.HEAD?.behind) {
|
||||
const pull = vscode.l10n.t('Pull Changes & Copy Link');
|
||||
const selection = await vscode.window.showInformationMessage(
|
||||
vscode.l10n.t('The current branch is not up to date. Would you like to pull before copying a link?'),
|
||||
{ modal: true },
|
||||
pull
|
||||
);
|
||||
if (selection !== pull) {
|
||||
throw new vscode.CancellationError();
|
||||
}
|
||||
|
||||
await repository.pull();
|
||||
}
|
||||
|
||||
await repository.status();
|
||||
|
|
Loading…
Reference in a new issue