Rev 25: Support setting a custom Author and Author Timestamp. in http://bzr.arbash-meinel.com/plugins/git
John Arbash Meinel
john at arbash-meinel.com
Fri Nov 9 16:59:13 GMT 2007
At http://bzr.arbash-meinel.com/plugins/git
------------------------------------------------------------
revno: 25
revision-id:john at arbash-meinel.com-20071109165902-13hctijmgzkt9io5
parent: john at arbash-meinel.com-20071109155623-drmfwv9j1nhaol64
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: git
timestamp: Fri 2007-11-09 11:59:02 -0500
message:
Support setting a custom Author and Author Timestamp.
modified:
tests/__init__.py __init__.py-20070202180350-njrb42t7fnv35d1k-2
tests/test_builder.py test_builder.py-20071109060756-yqmwmyqdr3pqeh3s-1
-------------- next part --------------
=== modified file 'tests/__init__.py'
--- a/tests/__init__.py 2007-11-09 15:53:24 +0000
+++ b/tests/__init__.py 2007-11-09 16:59:02 +0000
@@ -141,8 +141,8 @@
# TODO: Author
# TODO: Author timestamp+timezone
- def commit(self, committer, message, timestamp=None,
- timezone='+0000', author=None,
+ def commit(self, committer, message, timestamp=None, timezone='+0000',
+ author=None, author_ts=None, author_tz=None,
merge=None, base=None):
"""Commit the new content.
@@ -152,6 +152,9 @@
:param timezone: The timezone of the commit, such as '+0000' or '-1000'
:param author: The name and address of the author (if different from
committer)
+ :param author_ts: The timestamp of the author's commit, will be taken
+ from timestamp if not supplied, but author is supplied
+ :param author_tz: The timezone of the author's commit
:param merge: A list of marks if this should merge in another commit
:param base: An id for the base revision (primary parent) if that
is not the last commit.
@@ -164,6 +167,13 @@
timestamp = int(time.time())
self._write('commit %s\n' % (self._branch,))
self._write('mark :%d\n' % (mark,))
+ if author is not None:
+ if author_ts is None:
+ author_ts = timestamp
+ if author_tz is None:
+ author_tz = timezone
+ self._write('author %s %s %s\n'
+ % (author, author_ts, author_tz))
self._write('committer %s %s %s\n'
% (committer, timestamp, timezone))
message = message.encode('UTF-8')
=== modified file 'tests/test_builder.py'
--- a/tests/test_builder.py 2007-11-09 15:53:24 +0000
+++ b/tests/test_builder.py 2007-11-09 16:59:02 +0000
@@ -182,6 +182,44 @@
self.assertContainsRe(stream.getvalue(),
r'committer Joe Foo <joe at foo\.com> \d+ \+0000')
+ def test_author_same_timestamp(self):
+ stream = StringIO()
+ builder = tests.GitBranchBuilder(stream)
+ builder.commit('Joe Foo <joe at foo.com>', u'message',
+ timestamp=1194586415, timezone='+0100',
+ author='Jerry Bar <jerry at bar.com>',
+ )
+ self.assertEqualDiff(
+ 'commit refs/head/master\n'
+ 'mark :1\n'
+ 'author Jerry Bar <jerry at bar.com> 1194586415 +0100\n'
+ 'committer Joe Foo <joe at foo.com> 1194586415 +0100\n'
+ 'data 7\n'
+ 'message'
+ '\n'
+ '\n',
+ stream.getvalue())
+
+ def test_author_custom_time(self):
+ stream = StringIO()
+ builder = tests.GitBranchBuilder(stream)
+ builder.commit('Joe Foo <joe at foo.com>', u'message',
+ timestamp=1194586415, timezone='+0100',
+ author='Jerry Bar <jerry at bar.com>',
+ author_ts=1194000000, author_tz='-1000',
+ )
+ self.assertEqualDiff(
+ 'commit refs/head/master\n'
+ 'mark :1\n'
+ 'author Jerry Bar <jerry at bar.com> 1194000000 -1000\n'
+ 'committer Joe Foo <joe at foo.com> 1194586415 +0100\n'
+ 'data 7\n'
+ 'message'
+ '\n'
+ '\n',
+ stream.getvalue())
+
+
class TestGitBranchBuilderReal(tests.TestCaseInTempDir):
More information about the bazaar-commits
mailing list