Skip to content

Commit e306802

Browse files
committed
added tests for commits with dates
1 parent 141b78f commit e306802

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎git/index/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,8 @@ def move(self, items, skip_errors=False, **kwargs):
922922

923923
return out
924924

925-
def commit(self, message, parent_commits=None, head=True, author=None, committer=None, author_date=None, commit_date=None):
925+
def commit(self, message, parent_commits=None, head=True, author=None,
926+
committer=None, author_date=None, commit_date=None):
926927
"""Commit the current default index file, creating a commit object.
927928
For more information on the arguments, see tree.commit.
928929

‎git/test/test_index.py

+11
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,17 @@ def mixed_iterator():
470470
assert cur_head.commit == commit_actor
471471
assert cur_head.log()[-1].actor == my_committer
472472

473+
# commit with author_date and commit_date
474+
cur_commit = cur_head.commit
475+
commit_message = u"commit with dates by Avinash Sajjanshetty"
476+
477+
new_commit = index.commit(commit_message, author_date="2006-04-07T22:13:13", commit_date="2005-04-07T22:13:13")
478+
assert cur_commit != new_commit
479+
print(new_commit.authored_date, new_commit.committed_date)
480+
assert new_commit.message == commit_message
481+
assert new_commit.authored_date == 1144447993
482+
assert new_commit.committed_date == 1112911993
483+
473484
# same index, no parents
474485
commit_message = "index without parents"
475486
commit_no_parents = index.commit(commit_message, parent_commits=list(), head=True)

0 commit comments

Comments
 (0)