Skip to content

Conversation

mildsunrise
Copy link
Contributor

There's no easy way to re-create a commit (i.e. for rewriting purposes), because dates must be formatted as strings, passed, then parsed back.

This patch allows parse_date() to accept datetime instances, such as those produced by from_timestamp().
Re-creating a commit is then possible:

Commit.create_from_tree(
  repo=commit.repo,
  tree=commit.tree,
  message=commit.message,
  parent_commits=commit.parents,
  author=commit.author,
  author_date=commit.authored_datetime,
  committer=commit.committer,
  commit_date=commit.committed_datetime,
)

There's no easy way to re-create a commit (i.e. for rewriting purposes), because dates must be formatted as strings, passed, then parsed back.

This patch allows parse_date() to accept datetime instances, such as those produced by from_timestamp() above.
@Byron Byron added this to the v3.1.8 - Bugfixes milestone Aug 31, 2020
@Byron
Copy link
Member

Byron commented Aug 31, 2020

Thanks a lot for your contribution.
It looks great 👍!

@Byron Byron merged commit 98595da into gitpython-developers:master Aug 31, 2020
@mildsunrise mildsunrise deleted the accept-datetime branch August 31, 2020 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants