Skip to content

Commit

Permalink
Fix appending trailers to git commits
Browse files Browse the repository at this point in the history
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.

Change-Id: I06fe0bfd47c008b3554d1c6cd06bd140997f3128
  • Loading branch information
bjh83 committed Jan 20, 2021
1 parent bb4052b commit 6eb5e5e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
f.write(original_message)
f.flush()
self._git('interpret-trailers', '--in-place', '--if-exists=addIfDifferent',
'--trailer', change_id_trailer, '--trailer', lore_trailer, f.name)
return self._git.commit('--amend', '-F', f.name)
Expand Down

0 comments on commit 6eb5e5e

Please sign in to comment.