Merged
Conversation
I couldn't get the diff as shown in the git-show recipe. Therefore update it to what I think it should be. Maybe there is a better way. Also add a section on how to assemble a git show-like message. It took me quite some searching in the Python docs to find out how to do it, especially the date and time part. So this might save people time. I wanted to add something that gives me a git show --stat equivalent, but couldn't figure it out.
docs/recipes/git-show.rst
Outdated
Member
There was a problem hiding this comment.
I think we should prefer to recommend repo.diff(commit.parents[0], commit) here, as that accepts treeishes in a few forms.
Make the diff generation more idiomatic and fix the assembling of the timestamp. git-show normally prints the author time, so use this instead of the commit time. Also fix how tzinfo is obtained. Of course we have to use the author's time zone and not some fixed one as I had written before.
docs/recipes/git-show.rst
Outdated
Member
There was a problem hiding this comment.
The timezone (really offset) is not fixed for the user running git-show, but is read from the commit, in this case from commit.author.time_offset.
Contributor
Author
There was a problem hiding this comment.
Have a look at my new commit. I fixed it there already.
Member
|
Python 3.2+ has a new |
Contributor
Author
|
Thanks for pointing that out. I will upload the patch as soon as I've managed to install pygit2 under Python 3. |
As @jdavid pointed out, Python 3 already provides a tzinfo subclass for fixed UTC offsets. Incorporate this in the recipe. Leave the old code with the self-made class, since many people are working with Python 2 and it is harder to find out there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I couldn't get the diff as shown in the git-show recipe. Therefore
update it to what I think it should be. Maybe there is a better way.
Also add a section on how to assemble a git show-like message. It took
me quite some searching in the Python docs to find out how to do it,
especially the date and time part. So this might save people time. I
wanted to add something that gives me a git show --stat equivalent, but
couldn't figure it out.