Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share > Copy vscode.dev Link polish #186576

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions extensions/github/src/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -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(
Expand All @@ -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 },
Expand All @@ -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();
Expand Down