-
-
Notifications
You must be signed in to change notification settings - Fork 399
Update git-show recipe #491
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ Show SHA hash | |
Show diff | ||
====================================================================== | ||
|
||
>>> diff = commit.tree.diff() | ||
>>> diff = commit.parents[0].tree.diff_to_tree(commit.tree) | ||
|
||
====================================================================== | ||
Show all files in commit | ||
|
@@ -40,6 +40,22 @@ Show all files in commit | |
>>> for e in commit.tree: | ||
>>> print(e.name) | ||
|
||
====================================================================== | ||
Produce something like a `git show` message | ||
====================================================================== | ||
|
||
>>> from __future__ import unicode_literals | ||
>>> from datetime import datetime | ||
>>> import pytz | ||
>>> tzinfo = pytz.timezone('Europe/Berlin') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The timezone (really offset) is not fixed for the user running git-show, but is read from the commit, in this case from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have a look at my new commit. I fixed it there already. |
||
>>> dt = datetime.fromtimestamp(float(commit.commit_time), tzinfo) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. git-show/git-log use the author time rather than commit time. In order to show what it would show, we'd want to use |
||
>>> timestr = dt.strftime('%c %z') | ||
>>> msg = '\n'.join(['commit {}'.format(commit.tree_id.hex), | ||
... 'Author: {} <{}>'.format(commit.author.name, commit.author.email), | ||
... 'Date: {}'.format(timestr), | ||
... '', | ||
... commit.message]) | ||
|
||
---------------------------------------------------------------------- | ||
References | ||
---------------------------------------------------------------------- | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should prefer to recommend
repo.diff(commit.parents[0], commit)
here, as that accepts treeishes in a few forms.