@@ -64,15 +64,18 @@ public void Refresh()
6464 /// <returns>An UriString with the generated url, or null if the repository has no remote server configured or if it can't be found locally</returns>
6565 public UriString GenerateUrl ( string path = null , int startLine = - 1 , int endLine = - 1 )
6666 {
67- var sha = HeadSha ;
68- if ( CloneUrl == null || String . IsNullOrEmpty ( sha ) )
67+ if ( CloneUrl == null )
6968 return null ;
7069
70+ var sha = HeadSha ;
71+ // this also incidentally checks whether the repo has a valid LocalPath
72+ if ( String . IsNullOrEmpty ( sha ) )
73+ return CloneUrl . ToRepositoryUrl ( ) . AbsoluteUri ;
74+
7175 if ( path != null && Path . IsPathRooted ( path ) )
7276 {
7377 // if the path root doesn't match the repository local path, then ignore it
74- if ( LocalPath == null ||
75- ! path . StartsWith ( LocalPath , StringComparison . OrdinalIgnoreCase ) )
78+ if ( ! path . StartsWith ( LocalPath , StringComparison . OrdinalIgnoreCase ) )
7679 {
7780 Debug . Assert ( false , String . Format ( CultureInfo . CurrentCulture , "GenerateUrl: path {0} doesn't match repository {1}" , path , LocalPath ) ) ;
7881 path = null ;
@@ -81,7 +84,7 @@ public UriString GenerateUrl(string path = null, int startLine = -1, int endLine
8184 path = path . Substring ( LocalPath . Length + 1 ) ;
8285 }
8386
84- return new UriString ( GenerateUrl ( cloneUrl . ToRepositoryUrl ( ) . AbsoluteUri , sha , path , startLine , endLine ) ) ;
87+ return new UriString ( GenerateUrl ( CloneUrl . ToRepositoryUrl ( ) . AbsoluteUri , sha , path , startLine , endLine ) ) ;
8588 }
8689
8790 const string CommitFormat = "{0}/commit/{1}" ;
0 commit comments