@@ -33,6 +33,30 @@ def checkForIncompatibleModuleVersions():
3333
3434checkForIncompatibleModuleVersions ()
3535
36+ def returnGitCommitId ():
37+ """ if we are in a git-managed repository, return the git commit id """
38+ try :
39+ import subprocess
40+ # Check if we're inside a Git repository
41+ subprocess .run (
42+ ['git' , 'rev-parse' , '--is-inside-work-tree' ],
43+ stdout = subprocess .DEVNULL ,
44+ stderr = subprocess .DEVNULL ,
45+ check = True
46+ )
47+
48+ # Get the current commit hash
49+ commit = subprocess .check_output (
50+ ['git' , 'rev-parse' , 'HEAD' ],
51+ stderr = subprocess .DEVNULL
52+ ).decode ('utf-8' ).strip ()
53+
54+ return commit
55+
56+ except subprocess .CalledProcessError :
57+ # Not a Git repo, or git command failed—do nothing
58+ return None
59+
3660def printEnvironmentInfo ( args : Dict ):
3761 """ very simple method that prints out info relevant to debugging
3862 machine-dependent problems
@@ -63,6 +87,9 @@ def printEnvironmentInfo( args : Dict ):
6387 except ImportError :
6488 print (f"{ module_name :<12} : Not installed" )
6589 depsMet = False
90+ gitId = returnGitCommitId ()
91+ if gitId != None :
92+ print ( f"\n git commit: { gitId } " )
6693 return depsMet
6794
6895def filetype ( filename : os .PathLike ) -> Union [Text ,None ]:
0 commit comments