@@ -26,15 +26,23 @@ public interface IGitRepository
2626// It uses `git pull --depth 1` and `git fetch --depth 1` to minimize the amount of data transferred.
2727public class SingleCommitOptimizedGitRepository ( DiagnosticsCollector collector , IDirectoryInfo workingDirectory ) : ExternalCommandExecutor ( collector , workingDirectory ) , IGitRepository
2828{
29+ private static readonly Dictionary < string , string > EnvironmentVars = new ( )
30+ {
31+ // Disable git editor prompts:
32+ // There are cases where `git pull` would prompt for an editor to write a commit message.
33+ // This env variable prevents that.
34+ { "GIT_EDITOR" , "true" }
35+ } ;
36+
2937 public string GetCurrentCommit ( ) => Capture ( "git" , "rev-parse" , "HEAD" ) ;
3038
31- public void Init ( ) => ExecIn ( "git" , "init" ) ;
39+ public void Init ( ) => ExecIn ( EnvironmentVars , "git" , "init" ) ;
3240 public bool IsInitialized ( ) => Directory . Exists ( Path . Combine ( WorkingDirectory . FullName , ".git" ) ) ;
33- public void Pull ( string branch ) => ExecIn ( "git" , "pull" , "--depth" , "1" , "--allow-unrelated-histories" , "--no-ff" , "origin" , branch ) ;
34- public void Fetch ( string reference ) => ExecIn ( "git" , "fetch" , "--no-tags" , "--prune" , "--no-recurse-submodules" , "--depth" , "1" , "origin" , reference ) ;
35- public void EnableSparseCheckout ( string folder ) => ExecIn ( "git" , "sparse-checkout" , "set" , folder ) ;
36- public void DisableSparseCheckout ( ) => ExecIn ( "git" , "sparse-checkout" , "disable" ) ;
37- public void Checkout ( string reference ) => ExecIn ( "git" , "checkout" , "--force" , reference ) ;
41+ public void Pull ( string branch ) => ExecIn ( EnvironmentVars , "git" , "pull" , "--depth" , "1" , "--allow-unrelated-histories" , "--no-ff" , "origin" , branch ) ;
42+ public void Fetch ( string reference ) => ExecIn ( EnvironmentVars , "git" , "fetch" , "--no-tags" , "--prune" , "--no-recurse-submodules" , "--depth" , "1" , "origin" , reference ) ;
43+ public void EnableSparseCheckout ( string folder ) => ExecIn ( EnvironmentVars , "git" , "sparse-checkout" , "set" , folder ) ;
44+ public void DisableSparseCheckout ( ) => ExecIn ( EnvironmentVars , "git" , "sparse-checkout" , "disable" ) ;
45+ public void Checkout ( string reference ) => ExecIn ( EnvironmentVars , "git" , "checkout" , "--force" , reference ) ;
3846
39- public void GitAddOrigin ( string origin ) => ExecIn ( "git" , "remote" , "add" , "origin" , origin ) ;
47+ public void GitAddOrigin ( string origin ) => ExecIn ( EnvironmentVars , "git" , "remote" , "add" , "origin" , origin ) ;
4048}
0 commit comments