-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fix appending trailers to git commits #33
Conversation
Commit message has a change-id in it? |
src/git.py
Outdated
@@ -121,8 +121,10 @@ def _set_trailers(self, patch: Patch) -> str: | |||
# Add trailers, changing them if they exist. | |||
# It's _highly_ unlikely that they'd exist, but this seems to be the | |||
# most sane way of handling that edge case. | |||
with tempfile.NamedTemporaryFile(mode='wt') as f: | |||
with tempfile.NamedTemporaryFile(mode='w+') as f: | |||
f.seek(0, os.SEEK_END) |
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'm not sure what this seek does/if it's necessary.
Perhaps a comment is in order?
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 could have sworn that it didn't work without it, but I just tried it without the seek and it appears to work.
Will fix.
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.
Done.
src/git.py
Outdated
f.write(original_message) | ||
f.flush() |
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.
can we have a comment like
# flush before we write to the file externally below
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.
Done.
Previously trailers were not properly added to end of git commit messages. Apparently, trailers were overwriting the entire message because the file was not opened and flushed properly. Signed-off-by: Brendan Higgins <brendanhiggins@google.com>
Codecov Report
@@ Coverage Diff @@
## master #33 +/- ##
==========================================
- Coverage 81.25% 81.18% -0.08%
==========================================
Files 13 13
Lines 1115 1116 +1
==========================================
Hits 906 906
- Misses 209 210 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
LGTM.
I also forgot this wasn't submitted.
Previously trailers were not properly added to end of git commit
messages. Apparently, trailers were overwriting the entire message
because the file was not opened and flushed properly.