@@ -41,6 +41,7 @@ public class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDet
4141 string operationError ;
4242 bool isBusy ;
4343 bool isLoading ;
44+ bool isCheckedOut ;
4445 bool isFromFork ;
4546 bool isInCheckout ;
4647
@@ -105,7 +106,7 @@ public PullRequestDetailViewModel(
105106 SubscribeOperationError ( Push ) ;
106107
107108 OpenOnGitHub = ReactiveCommand . Create ( ) ;
108- OpenFile = ReactiveCommand . Create ( ) ;
109+ OpenFile = ReactiveCommand . Create ( this . WhenAnyValue ( x => x . IsCheckedOut ) ) ;
109110 DiffFile = ReactiveCommand . Create ( ) ;
110111 }
111112
@@ -156,6 +157,14 @@ public bool IsBusy
156157 private set { this . RaiseAndSetIfChanged ( ref isBusy , value ) ; }
157158 }
158159
160+ /// Gets a value indicating whether the pull request branch is checked out.
161+ /// </summary>
162+ public bool IsCheckedOut
163+ {
164+ get { return isCheckedOut ; }
165+ private set { this . RaiseAndSetIfChanged ( ref isCheckedOut , value ) ; }
166+ }
167+
159168 /// <summary>
160169 /// Gets a value indicating whether the view model is loading.
161170 /// </summary>
@@ -289,9 +298,10 @@ public async Task Load(IPullRequestModel pullRequest)
289298 ChangedFilesTree = CreateChangedFilesTree ( pullRequest , changes ) . Children . ToList ( ) ;
290299
291300 var localBranches = await pullRequestsService . GetLocalBranches ( repository , pullRequest ) . ToList ( ) ;
292- var isCheckedOut = localBranches . Contains ( repository . CurrentBranch ) ;
293301
294- if ( isCheckedOut )
302+ IsCheckedOut = localBranches . Contains ( repository . CurrentBranch ) ;
303+
304+ if ( IsCheckedOut )
295305 {
296306 var divergence = await pullRequestsService . CalculateHistoryDivergence ( repository , Model . Number ) ;
297307 var pullEnabled = divergence . BehindBy > 0 ;
@@ -360,25 +370,24 @@ public async Task Load(IPullRequestModel pullRequest)
360370 }
361371
362372 /// <summary>
363- /// Gets the specified file as it appears in the pull request .
373+ /// Gets the before and after files needed for viewing a diff .
364374 /// </summary>
365- /// <param name="file">The file or directory node .</param>
366- /// <returns>The path to the extracted file .</returns>
367- public Task < string > ExtractFile ( IPullRequestFileNode file )
375+ /// <param name="file">The changed file .</param>
376+ /// <returns>A tuple containing the full path to the before and after files .</returns>
377+ public Task < Tuple < string , string > > ExtractDiffFiles ( IPullRequestFileNode file )
368378 {
369379 var path = Path . Combine ( file . DirectoryPath , file . FileName ) ;
370- return pullRequestsService . ExtractFile ( repository , modelService , model . Head . Sha , path , file . Sha ) . ToTask ( ) ;
380+ return pullRequestsService . ExtractDiffFiles ( repository , modelService , model , path , file . Sha , IsCheckedOut ) . ToTask ( ) ;
371381 }
372382
373383 /// <summary>
374- /// Gets the before and after files needed for viewing a diff .
384+ /// Gets the full path to a file in the working directory .
375385 /// </summary>
376- /// <param name="file">The changed file.</param>
377- /// <returns>A tuple containing the full path to the before and after files .</returns>
378- public Task < Tuple < string , string > > ExtractDiffFiles ( IPullRequestFileNode file )
386+ /// <param name="file">The file.</param>
387+ /// <returns>The full path to the file in the working directory .</returns>
388+ public string GetLocalFilePath ( IPullRequestFileNode file )
379389 {
380- var path = Path . Combine ( file . DirectoryPath , file . FileName ) ;
381- return pullRequestsService . ExtractDiffFiles ( repository , modelService , model , path , file . Sha ) . ToTask ( ) ;
390+ return Path . Combine ( repository . LocalPath , file . DirectoryPath , file . FileName ) ;
382391 }
383392
384393 void SubscribeOperationError ( ReactiveCommand < Unit > command )
0 commit comments