Skip to content
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

Accept datetime instances as dates #1050

Merged
merged 2 commits into from Aug 31, 2020

Conversation

@mildsunrise
Copy link
Contributor

@mildsunrise mildsunrise commented Aug 31, 2020

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,
)
@mildsunrise mildsunrise force-pushed the mildsunrise:accept-datetime branch from af575c6 to c45d5a5 Aug 31, 2020
mildsunrise added 2 commits Aug 31, 2020
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.
@mildsunrise mildsunrise force-pushed the mildsunrise:accept-datetime branch from c45d5a5 to 5e61cea Aug 31, 2020
@Byron Byron added this to the v3.1.8 - Bugfixes milestone Aug 31, 2020
@Byron
Copy link
Member

@Byron 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
4 checks passed
4 checks passed
build (3.5)
Details
build (3.6)
Details
build (3.7)
Details
build (3.8)
Details
@mildsunrise mildsunrise deleted the mildsunrise:accept-datetime branch Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.