@@ -21,37 +21,33 @@ def have_git() -> bool:
2121 return False
2222
2323
24- def run_in_dir (dir , command ) -> bytes :
25- """Convenience function: Run a command in a directory."""
26- return subprocess .check_output ("cd " + pipes .quote (dir ) + "; " + command ,
27- shell = True )
28-
29-
3024def get_submodules (dir : str ):
3125 """Return a list of all git top-level submodules in a given directory."""
3226 # It would be nicer to do
3327 # "git submodule foreach 'echo MODULE $name $path $sha1 $toplevel'"
3428 # but that wouldn't work on Windows.
35- output = run_in_dir ( dir , "git submodule status" )
29+ output = subprocess . check_output ([ "git" , " submodule" , " status"], cwd = dir )
3630 for line in output .splitlines ():
3731 status = line [0 ]
38- sha5 , name , * _ = line [1 :].split (b" " )
39- yield (status , sha5 , name .decode (sys .getfilesystemencoding ()))
32+ revision , name , * _ = line [1 :].split (b" " )
33+ yield (status , revision , name .decode (sys .getfilesystemencoding ()))
4034
4135
4236def git_revision (dir : str ) -> bytes :
4337 """Get the SHA-1 of the HEAD of a git repository."""
44- return run_in_dir ( dir , "git rev-parse HEAD" ).strip ()
38+ return subprocess . check_output ([ "git" , " rev-parse" , " HEAD"], cwd = dir ).strip ()
4539
4640
4741def is_dirty (dir : str ) -> bool :
4842 """Check whether a git repository has uncommitted changes."""
49- return run_in_dir (dir , "git status -uno --porcelain" ).strip () != b""
43+ output = subprocess .check_output (["git" , "status" , "-uno" , "--porcelain" ], cwd = dir )
44+ return output .strip () != b""
5045
5146
5247def has_extra_files (dir : str ) -> bool :
5348 """Check whether a git repository has untracked files."""
54- return run_in_dir (dir , "git clean --dry-run -d" ).strip () != b""
49+ output = subprocess .check_output (["git" , "clean" , "--dry-run" , "-d" ], cwd = dir )
50+ return output .strip () != b""
5551
5652
5753def warn_no_git_executable () -> None :
@@ -62,11 +58,17 @@ def warn_no_git_executable() -> None:
6258def warn_dirty (dir ) -> None :
6359 print ("Warning: git module '{}' has uncommitted changes." .format (dir ),
6460 file = sys .stderr )
61+ print ("Got to the directory" , file = sys .stderr )
62+ print (" {}" .format (dir ), file = sys .stderr )
63+ print ("and commit or reset your changes" , file = sys .stderr )
6564
6665
6766def warn_extra_files (dir ) -> None :
6867 print ("Warning: git module '{}' has untracked files." .format (dir ),
6968 file = sys .stderr )
69+ print ("Got to the directory" , file = sys .stderr )
70+ print (" {}" .format (dir ), file = sys .stderr )
71+ print ("and add & commit your new files." , file = sys .stderr )
7072
7173
7274def error_submodule_not_initialized (name : str , dir : str ) -> None :
@@ -81,6 +83,8 @@ def error_submodule_not_updated(name: str, dir: str) -> None:
8183 print ("Please run:" , file = sys .stderr )
8284 print (" cd {}" .format (pipes .quote (dir )), file = sys .stderr )
8385 print (" git submodule update {}" .format (name ), file = sys .stderr )
86+ print ("(If you got this message because you updated {}" .format (name ), file = sys .stderr )
87+ print (" then run \" git add {}\" to silence this check)" )
8488
8589
8690def verify_git_integrity_or_abort (datadir : str ) -> None :
0 commit comments