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