extend git.get_commit_info to get commit file status
authorZhang Qiang <qiang.z.zhang@intel.com>
Fri, 8 Jun 2012 01:31:13 +0000 (09:31 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Fri, 8 Jun 2012 01:31:13 +0000 (09:31 +0800)
gbp/git/repository.py

index 1e27452b1eb0708f071a3cdf9242fed846226249..5730ce0b35affd8cb68d6b89be7a911e6471b945 100644 (file)
@@ -19,6 +19,7 @@
 import re
 import subprocess
 import os.path
+from collections import defaultdict
 
 import gbp.log as log
 from gbp.command_wrappers import (GitCommand, CommandExecFailed)
@@ -1130,16 +1131,26 @@ class GitRepository(object):
         """
         out, ret =  self._git_getoutput('log',
                                          ['--pretty=format:%an%n%ae%n%at%n%s%n%b%n',
-                                          '-n1', commit])
+                                          '-n1', '--name-status', commit])
         if ret:
             raise GitRepositoryError("Unable to retrieve log entry for %s"
                                      % commit)
+
+        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)
+
         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:]]}
+                'body' : [line.rstrip() for line in  out[4:]],
+                'files' : files}
 
 
 #{ Patches