Skip to content

Commit

Permalink
Repair new with patchdescr.template (#87)
Browse files Browse the repository at this point in the history
When a user-provided patchdescr.tmpl is present, `stg new` would crash
with a TypeError due to a str/bytes mismatch.

Repairs #87.

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
  • Loading branch information
jpgrayson committed Dec 7, 2020
1 parent c3f7d39 commit 93c9073
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stgit/commands/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def update_commit_data(cd, message=None, author=None, sign_str=None, edit=False)
if edit:
tmpl = templates.get_template('patchdescr.tmpl')
if tmpl:
cd = cd.set_message(cd.message + tmpl)
cd = cd.set_message(cd.message_str + tmpl)
cd = cd.set_message(edit_bytes(cd.message, '.stgit-new.txt'))

return cd
Expand Down
7 changes: 7 additions & 0 deletions t/t1003-new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ test_expect_success \
test_path_is_file new-tmpl.txt
'

test_expect_success \
'New with patchdescr.tmpl' '
echo "Patch Description Template" > .git/patchdescr.tmpl &&
stg new templated-patch &&
stg show | grep "Patch Description Template"
'

test_expect_failure \
'Patch with slash in name' '
stg new bar/foo -m "patch bar/foo"
Expand Down

0 comments on commit 93c9073

Please sign in to comment.