Skip to content

Accept datetime instances as dates #1050

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
Aug 31, 2020

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