@@ -195,7 +195,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
195
195
// If HEAD is not published, make sure it is
196
196
&& ! repository ?. state . HEAD ?. upstream
197
197
) {
198
- const publishBranch = vscode . l10n . t ( 'Publish Branch' ) ;
198
+ const publishBranch = vscode . l10n . t ( 'Publish Branch & Copy Link ' ) ;
199
199
const selection = await vscode . window . showInformationMessage (
200
200
vscode . l10n . t ( 'The current branch is not published to the remote. Would you like to publish your branch before copying a link?' ) ,
201
201
{ modal : true } ,
@@ -209,7 +209,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
209
209
}
210
210
211
211
const uncommittedChanges = [ ...repository . state . workingTreeChanges , ...repository . state . indexChanges ] ;
212
- if ( uncommittedChanges . find ( ( c ) => c . uri . toString ( ) === file . toString ( ) ) ) {
212
+ if ( uncommittedChanges . find ( ( c ) => c . uri . toString ( ) === file . toString ( ) ) && ! repository . state . HEAD ?. ahead && ! repository . state . HEAD ?. behind ) {
213
213
const commitChanges = vscode . l10n . t ( 'Commit Changes' ) ;
214
214
const copyAnyway = vscode . l10n . t ( 'Copy Anyway' ) ;
215
215
const selection = await vscode . window . showWarningMessage (
@@ -225,7 +225,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
225
225
throw new vscode . CancellationError ( ) ;
226
226
}
227
227
} else if ( repository . state . HEAD ?. ahead ) {
228
- const pushCommits = vscode . l10n . t ( 'Push Commits' ) ;
228
+ const pushCommits = vscode . l10n . t ( 'Push Commits & Copy Link ' ) ;
229
229
const selection = await vscode . window . showInformationMessage (
230
230
vscode . l10n . t ( 'The current branch has unpublished commits. Would you like to push your commits before copying a link?' ) ,
231
231
{ modal : true } ,
@@ -236,6 +236,18 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
236
236
}
237
237
238
238
await repository . push ( ) ;
239
+ } else if ( repository . state . HEAD ?. behind ) {
240
+ const pull = vscode . l10n . t ( 'Pull Changes & Copy Link' ) ;
241
+ const selection = await vscode . window . showInformationMessage (
242
+ vscode . l10n . t ( 'The current branch is not up to date. Would you like to pull before copying a link?' ) ,
243
+ { modal : true } ,
244
+ pull
245
+ ) ;
246
+ if ( selection !== pull ) {
247
+ throw new vscode . CancellationError ( ) ;
248
+ }
249
+
250
+ await repository . pull ( ) ;
239
251
}
240
252
241
253
await repository . status ( ) ;
0 commit comments