Skip to content

Commit

Permalink
Merge pull request #71 from varac/commit_time
Browse files Browse the repository at this point in the history
Add commit_info.time
  • Loading branch information
ionelmc committed Mar 29, 2017
2 parents 11c2b52 + d60fdea commit 19d5124
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pytest_benchmark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def cmd(s):
def get_commit_info(project_name=None):
dirty = False
commit = 'unversioned'
commit_time = None
project_name = project_name or get_project_name()
branch = get_branch_info()
try:
Expand All @@ -186,20 +187,26 @@ def get_commit_info(project_name=None):
dirty = True
desc.pop()
commit = desc[-1].strip('g')
commit_time = check_output('git show -s --pretty=format:"%cI"'.split(),
universal_newlines=True).strip().strip('"')
elif in_any_parent('.hg'):
desc = check_output('hg id --id --debug'.split(), universal_newlines=True).strip()
if desc[-1] == '+':
dirty = True
commit = desc.strip('+')
commit_time = check_output('hg tip --template "{date|rfc3339date}"'.split(),
universal_newlines=True).strip().strip('"')
return {
'id': commit,
'time': commit_time,
'dirty': dirty,
'project': project_name,
'branch': branch,
}
except Exception as exc:
return {
'id': 'unknown',
'time': None,
'dirty': dirty,
'error': repr(exc),
'project': project_name,
Expand Down

0 comments on commit 19d5124

Please sign in to comment.