@@ -195,7 +195,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
195195 // If HEAD is not published, make sure it is
196196 && ! repository ?. state . HEAD ?. upstream
197197 ) {
198- const publishBranch = vscode . l10n . t ( 'Publish Branch' ) ;
198+ const publishBranch = vscode . l10n . t ( 'Publish Branch & Copy Link ' ) ;
199199 const selection = await vscode . window . showInformationMessage (
200200 vscode . l10n . t ( 'The current branch is not published to the remote. Would you like to publish your branch before copying a link?' ) ,
201201 { modal : true } ,
@@ -209,7 +209,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
209209 }
210210
211211 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 ) {
213213 const commitChanges = vscode . l10n . t ( 'Commit Changes' ) ;
214214 const copyAnyway = vscode . l10n . t ( 'Copy Anyway' ) ;
215215 const selection = await vscode . window . showWarningMessage (
@@ -225,7 +225,7 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
225225 throw new vscode . CancellationError ( ) ;
226226 }
227227 } else if ( repository . state . HEAD ?. ahead ) {
228- const pushCommits = vscode . l10n . t ( 'Push Commits' ) ;
228+ const pushCommits = vscode . l10n . t ( 'Push Commits & Copy Link ' ) ;
229229 const selection = await vscode . window . showInformationMessage (
230230 vscode . l10n . t ( 'The current branch has unpublished commits. Would you like to push your commits before copying a link?' ) ,
231231 { modal : true } ,
@@ -236,6 +236,18 @@ export async function ensurePublished(repository: Repository, file: vscode.Uri)
236236 }
237237
238238 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 ( ) ;
239251 }
240252
241253 await repository . status ( ) ;
0 commit comments