@@ -130,6 +130,14 @@ def get_current_git_branch(git_repo_path):
130
130
'--abbrev-ref' , 'HEAD' ], stderr = subprocess .STDOUT ).strip ()
131
131
132
132
133
+ def get_git_head_ID (git_repo_path ):
134
+ """Return the short identifier for the HEAD commit of the repo
135
+ `git_repo_path`"""
136
+ return subprocess .check_output (
137
+ ['git' , '-C' , git_repo_path , 'rev-parse' ,
138
+ '--short' , 'HEAD' ], stderr = subprocess .STDOUT ).strip ()
139
+
140
+
133
141
def log_results (log_directory , driver , formatted_output , swift_repo = None ):
134
142
"""Log `formatted_output` to a branch specific directory in
135
143
`log_directory`
@@ -138,6 +146,10 @@ def log_results(log_directory, driver, formatted_output, swift_repo=None):
138
146
branch = get_current_git_branch (swift_repo )
139
147
except (OSError , subprocess .CalledProcessError ):
140
148
branch = None
149
+ try :
150
+ head_ID = '-' + get_git_head_ID (swift_repo )
151
+ except (OSError , subprocess .CalledProcessError ):
152
+ head_ID = ''
141
153
timestamp = time .strftime ("%Y%m%d%H%M%S" , time .localtime ())
142
154
if branch :
143
155
output_directory = os .path .join (log_directory , branch )
@@ -149,7 +161,7 @@ def log_results(log_directory, driver, formatted_output, swift_repo=None):
149
161
except OSError :
150
162
pass
151
163
log_file = os .path .join (output_directory ,
152
- driver_name + '-' + timestamp + '.log' )
164
+ driver_name + '-' + timestamp + head_ID + '.log' )
153
165
print ('Logging results to: %s' % log_file )
154
166
with open (log_file , 'w' ) as f :
155
167
f .write (formatted_output )
0 commit comments