Skip to content

Feature: Make commits with custom author_date and commit_date (closes #315) #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 17, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added tests for commits with dates
  • Loading branch information
avinassh committed Jul 17, 2015
commit e3068025b64bee24efc1063aba5138708737c158
3 changes: 2 additions & 1 deletion git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,8 @@ def move(self, items, skip_errors=False, **kwargs):

return out

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

Expand Down
11 changes: 11 additions & 0 deletions git/test/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,17 @@ def mixed_iterator():
assert cur_head.commit == commit_actor
assert cur_head.log()[-1].actor == my_committer

# commit with author_date and commit_date
cur_commit = cur_head.commit
commit_message = u"commit with dates by Avinash Sajjanshetty"

new_commit = index.commit(commit_message, author_date="2006-04-07T22:13:13", commit_date="2005-04-07T22:13:13")
assert cur_commit != new_commit
print(new_commit.authored_date, new_commit.committed_date)
assert new_commit.message == commit_message
assert new_commit.authored_date == 1144447993
assert new_commit.committed_date == 1112911993

# same index, no parents
commit_message = "index without parents"
commit_no_parents = index.commit(commit_message, parent_commits=list(), head=True)
Expand Down