diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-06-18 16:20:39 +0300 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-06-19 08:03:29 +0300 |
commit | 5de0692fcfb0c63a295fb455736d5add610c482f (patch) | |
tree | e2a4d6d26d0fa32fe4ccc970c054b56b6e0dbbc8 | |
parent | 5196f2e97712aad9676434fb3f680e620b36d4d4 (diff) | |
download | git-buildpackage-2.0_alpha.tar.gz git-buildpackage-2.0_alpha.tar.bz2 git-buildpackage-2.0_alpha.zip |
Now uses git-show instead of git-log. This way we get the file status
for merge commits, too. Also, use null-character as the field separator
which makes parsing more reliable. For example, should handle exotic
filenames/paths reliably, now.
Also, 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>
-rw-r--r-- | gbp/git/repository.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index 9dcaac93..9387fbe1 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1159,27 +1159,25 @@ 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%at%n%s%n%b%n', - '-n1', '--name-status', commit]) + args = GitArgs('--pretty=format:%an%x00%ae%x00%at%x00%s%x00%b%x00', + '-z', '--name-status', commit) + out, err, ret = self._git_inout('show', args.args) if ret: raise GitRepositoryError("Unable to retrieve log entry for %s" % commit) + fields = out.split('\x00') files = defaultdict(list) - for line in reversed(out): - if not line.strip(): - break - key, val = line.strip().split(None, 1) - files[key].append(val) - out.remove(line) + starti = 5 if fields[5] != '' else 6 + for i in range(starti, len(fields)-1, 2): + files[fields[i].strip()].append(fields[i+1]) return {'id' : commit, - 'author' : out[0].strip(), - 'email' : out[1].strip(), - 'timestamp': out[2].strip(), - 'subject' : out[3].rstrip(), - 'body' : [line.rstrip() for line in out[4:]], + 'author' : fields[0].strip(), + 'email' : fields[1].strip(), + 'timestamp': fields[2].strip(), + 'subject' : fields[3].rstrip(), + 'body' : fields[4], 'files' : files} |