diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-05-31 10:20:36 +0300 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-07-27 13:45:51 +0200 |
commit | 7f9776f85055fd80549eb164aa8fffa4e0e5535f (patch) | |
tree | 5ab553459047fb6c3287461bd40007aaf5ac8887 | |
parent | f4da9649c81a18c5c3aee0e5cedcf3bab85eb033 (diff) | |
download | git-buildpackage-7f9776f85055fd80549eb164aa8fffa4e0e5535f.tar.gz git-buildpackage-7f9776f85055fd80549eb164aa8fffa4e0e5535f.tar.bz2 git-buildpackage-7f9776f85055fd80549eb164aa8fffa4e0e5535f.zip |
GitRepository/get_commit_info: add author timestamp
Add author timestamps to the info returned by get_commit_info() method.
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/git/repository.py | 11 | ||||
-rw-r--r-- | tests/test_GitRepository.py | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py index b45e5af1..3dde513c 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1209,8 +1209,8 @@ class GitRepository(object): @return: the commit's including id, author, email, subject and body @rtype: dict """ - args = GitArgs('--pretty=format:%an%x00%ae%x00%s%x00%b%x00', - '-z', '--quiet', commit) + args = GitArgs('--pretty=format:%an%x00%ae%x00%ad%x00%s%x00%b%x00', + '-z', '--quiet', '--date=raw', commit) out, err, ret = self._git_inout('show', args.args) if ret: raise GitRepositoryError("Unable to retrieve commit info for %s" @@ -1219,12 +1219,13 @@ class GitRepository(object): fields = out.split('\x00') author = GitModifier(fields[0].strip(), - fields[1].strip()) + fields[1].strip(), + fields[2].strip()) return {'id' : commit, 'author' : author, - 'subject' : fields[2], - 'body' : fields[3]} + 'subject' : fields[3], + 'body' : fields[4]} #{ Patches def format_patches(self, start, end, output_dir, signature=True, thread=None): diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index fe59cdfe..b91be61b 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -351,6 +351,7 @@ def test_get_commit_info(): - L{gbp.git.GitRepository.get_commit_info} >>> import gbp.git + >>> from datetime import datetime >>> repo = gbp.git.GitRepository(repo_dir) >>> info = repo.get_commit_info('HEAD') >>> info['id'] @@ -361,6 +362,9 @@ def test_get_commit_info(): 'foo' >>> '@' in info['author'].email True + >>> now = datetime.now() + >>> (now - datetime.fromtimestamp(int(info['author'].date.split()[0]))).seconds < 10 + True """ def test_mirror_clone(): |