fetchGit: Fix handling of local repo when not using 'master' branch
Add tests checking this behavior.
This commit is contained in:
		
							parent
							
								
									aa43cbb764
								
							
						
					
					
						commit
						2e6f06c37e
					
				
					 2 changed files with 31 additions and 1 deletions
				
			
		|  | @ -23,7 +23,7 @@ struct GitInfo | |||
| }; | ||||
| 
 | ||||
| GitInfo exportGit(ref<Store> store, const std::string & uri, | ||||
|     std::experimental::optional<std::string> ref, const std::string & rev, | ||||
|     std::experimental::optional<std::string> ref, std::string rev, | ||||
|     const std::string & name) | ||||
| { | ||||
|     if (!ref && rev == "" && hasPrefix(uri, "/") && pathExists(uri + "/.git")) { | ||||
|  | @ -68,6 +68,10 @@ GitInfo exportGit(ref<Store> store, const std::string & uri, | |||
| 
 | ||||
|             return gitInfo; | ||||
|         } | ||||
| 
 | ||||
|         // clean working tree, but no ref or rev specified.  Use 'HEAD'.
 | ||||
|         rev = chomp(runProgram("git", true, { "-C", uri, "rev-parse", "HEAD" })); | ||||
|         ref = "HEAD"s; | ||||
|     } | ||||
| 
 | ||||
|     if (!ref) ref = "master"s; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue