Skip to content

Commit 39e3e81

Browse files
committed
Extract 'tag' information for the given revision for Mercurial and Git repos
For Mercurial, do not save the 'tip' tag.
1 parent 17cba4b commit 39e3e81

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

codespeed/commits/git.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,21 @@ def getlogs(endrev, startrev):
6666
(short_commit_id, commit_id, date_t, author_name, author_email,
6767
subject, body) = log.split("\x00", 7)
6868

69+
tag = ""
70+
71+
cmd = ["git", "describe", "--tags", commit_id]
72+
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
73+
74+
stdout, stderr = p.communicate()
75+
76+
if p.returncode == 0:
77+
tag = stdout
78+
6979
date = datetime.datetime.fromtimestamp(
7080
int(date_t)).strftime("%Y-%m-%d %H:%M:%S")
7181

7282
logs.append({'date': date, 'message': subject, 'commitid': commit_id,
7383
'author': author_name, 'author_email': author_email,
74-
'body': body, 'short_commit_id': short_commit_id})
84+
'body': body, 'short_commit_id': short_commit_id, 'tag': tag})
7585

7686
return logs

codespeed/commits/mercurial.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def getlogs(endrev, startrev):
5050

5151
cmd = ["hg", "log",
5252
"-r", "%s::%s" % (startrev.commitid, endrev.commitid),
53-
"--template", "{rev}:{node|short}\n{node}\n{author|user}\n{author|email}\n{date}\n{desc}\n=newlog=\n"]
53+
"--template", "{rev}:{node|short}\n{node}\n{author|user}\n{author|email}\n{date}\n{tags}\n{desc}\n=newlog=\n"]
5454

5555
working_copy = endrev.branch.project.working_copy
5656
p = Popen(cmd, stdout=PIPE, stderr=PIPE, cwd=working_copy)
@@ -64,7 +64,7 @@ def getlogs(endrev, startrev):
6464
for log in stdout.split("=newlog=\n"):
6565
elements = []
6666
elements = log.split('\n')[:-1]
67-
if len(elements) < 6:
67+
if len(elements) < 7:
6868
# "Malformed" log
6969
logs.append(
7070
{'date': '-', 'message': 'error parsing log', 'commitid': '-'})
@@ -74,6 +74,8 @@ def getlogs(endrev, startrev):
7474
author_name = elements.pop(0)
7575
author_email = elements.pop(0)
7676
date = elements.pop(0)
77+
tag = elements.pop(0)
78+
tag = "" if tag == "tip" else tag
7779
# All other newlines should belong to the description text. Join.
7880
message = '\n'.join(elements)
7981

@@ -85,7 +87,7 @@ def getlogs(endrev, startrev):
8587
logs.append({
8688
'date': date, 'author': author_name,
8789
'author_email': author_email, 'message': message,
88-
'short_commit_id': short_commit_id, 'commitid': commit_id})
90+
'short_commit_id': short_commit_id, 'commitid': commit_id, 'tag': tag})
8991
# Remove last log here because mercurial saves the short hast as commitid now
9092
if len(logs) > 1 and logs[-1].get('short_commit_id') == startrev.commitid:
9193
logs.pop()

codespeed/results.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def save_result(data):
9797
rev.author = log['author']
9898
rev.date = log['date']
9999
rev.message = log['message']
100+
rev.tag = log['tag']
100101

101102
rev.save()
102103

0 commit comments

Comments
 (0)