summaryrefslogtreecommitdiff
path: root/gbp
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-06-18 16:20:39 +0300
committerGuido Günther <agx@sigxcpu.org>2012-06-30 09:35:03 +0200
commit1e8597804ff33ec7e826e77b94fd371d4be9ef29 (patch)
tree81af7335957ac2bab2339b316ffbe54ee2760cb7 /gbp
parent41482a3b5cd36ac7b1fd53079f2a05e5b4fbc99e (diff)
GitRepository: make get_commit_info() more robust
Now uses git-show instead of git-log. This is needed for further enhancements (namely to get name-status for merge commits). Also, use null-character as the field separator which makes parsing more reliable. The method now returns 'body' of the commit message as is, without stripping or splitting to lines. In addition, get_commit_info() now uses GitArgs and _git_inout() instead of the deprecated _git_getoutput(). Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp')
-rw-r--r--gbp/dch.py2
-rw-r--r--gbp/git/repository.py20
2 files changed, 12 insertions, 10 deletions
diff --git a/gbp/dch.py b/gbp/dch.py
index ddd5e8e..dc0149c 100644
--- a/gbp/dch.py
+++ b/gbp/dch.py
@@ -106,7 +106,7 @@ def format_changelog_entry(commit_info, options, last_commit=False):
GitRepository.get_commit_info()). If last_commit is not False,
then this entry is the last one in the series."""
entry = [commit_info['subject']]
- body = commit_info['body']
+ body = commit_info['body'].splitlines()
commitid = commit_info['id']
(git_dch_cmds, body) = extract_git_dch_cmds(body, options)
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index c4ac66c..2a8cdd8 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1192,17 +1192,19 @@ class GitRepository(object):
@return: the commit's including id, author, email, subject and body
@rtype: dict
"""
- out, ret = self._git_getoutput('log',
- ['--pretty=format:%an%n%ae%n%s%n%b%n',
- '-n1', commit])
- if ret:
- raise GitRepositoryError("Unable to retrieve log entry for %s"
+ args = GitArgs('--pretty=format:%an%x00%ae%x00%s%x00%b%x00',
+ '-z', '--quiet', commit)
+ out, err, ret = self._git_inout('show', args.args)
+ if ret > 1:
+ raise GitRepositoryError("Unable to retrieve commit info for %s"
% commit)
+
+ fields = out.split('\x00')
return {'id' : commit,
- 'author' : out[0].strip(),
- 'email' : out[1].strip(),
- 'subject' : out[2].rstrip(),
- 'body' : [line.rstrip() for line in out[3:]]}
+ 'author' : fields[0].strip(),
+ 'email' : fields[1].strip(),
+ 'subject' : fields[2],
+ 'body' : fields[3]}
#{ Patches