From 3362147479b89918a09efc8a698111e28c78f10c Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Tue, 30 Oct 2012 08:56:19 +0200 Subject: [PATCH] GitRepository/get_commit_info: support tags Dereference the given revision to a commit. Fixes get_commit_info() when called for a tag. Signed-off-by: Markus Lehtonen --- gbp/git/repository.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index b2df4ea..265ea3f 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1316,20 +1316,22 @@ class GitRepository(object): % commit) return out[0].strip() - def get_commit_info(self, commit): + def get_commit_info(self, commitish): """ - Look up data of a specific commit + Look up data of a specific commit-ish. Dereferences given commit-ish + to the commit it points to. - @param commit: the commit to inspect + @param commitish: the commit-ish to inspect @return: the commit's including id, author, email, subject and body @rtype: dict """ + commit_sha1 = self.rev_parse("%s^0" % commitish) args = GitArgs('--pretty=format:%an%x00%ae%x00%ad%x00%cn%x00%ce%x00%cd%x00%s%x00%b%x00', - '-z', '--date=raw', '--name-status', commit) + '-z', '--date=raw', '--name-status', commit_sha1) out, err, ret = self._git_inout('show', args.args) if ret: raise GitRepositoryError("Unable to retrieve commit info for %s" - % commit) + % commitish) fields = out.split('\x00') @@ -1349,7 +1351,7 @@ class GitRepository(object): path = file_fields.pop(0) files[status].append(path) - return {'id' : commit, + return {'id' : commitish, 'author' : author, 'committer' : committer, 'subject' : fields[6], -- 2.7.4