-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(squash): preserve consensus author
When all of the patches to be squashed have the same author, use that author for the squashed commit. If the patches to squash have heterogeneous authors, default to the configured user for the repo. (This was the behavior for all squashes.) The command line flags (--author, --authname, --authemail) still take precedence. Fixes: #490
- Loading branch information
Showing
2 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,54 @@ test_expect_success 'Squash at stack top' ' | |
[ "$(echo $(stg series --unapplied --noprefix))" = "" ] | ||
' | ||
|
||
test_expect_success 'Squash patches with all non-default author' ' | ||
echo "a" >>baz.txt && | ||
stg new -rm "a-patch" --author "Other Contributor <[email protected]>" && | ||
echo "b" >>baz.txt && | ||
stg new -rm "b-patch" --author "Other Contributor <[email protected]>" && | ||
echo "c" >>baz.txt && | ||
stg new -rm "c-patch" --author "Other Contributor <[email protected]>" && | ||
stg squash -m "abc-patch" a-patch b-patch c-patch && | ||
test_when_finished "stg delete abc-patch" && | ||
stg show abc-patch | grep "Author:" >out && | ||
cat >expected <<-\EOF && | ||
Author: Other Contributor <[email protected]> | ||
EOF | ||
test_cmp expected out | ||
' | ||
|
||
test_expect_success 'Squash patches with some non-default author' ' | ||
echo "a" >>baz.txt && | ||
stg new -rm "a-patch" && | ||
echo "b" >>baz.txt && | ||
stg new -rm "b-patch" --author "Other Contributor <[email protected]>" && | ||
echo "c" >>baz.txt && | ||
stg new -rm "c-patch" && | ||
stg squash -m "abc-patch" a-patch b-patch c-patch && | ||
test_when_finished "stg delete abc-patch" && | ||
stg show abc-patch | grep "Author:" >out && | ||
cat >expected <<-\EOF && | ||
Author: A Ú Thor <[email protected]> | ||
EOF | ||
test_cmp expected out | ||
' | ||
|
||
test_expect_success 'Squash patches with author override' ' | ||
echo "a" >>baz.txt && | ||
stg new -rm "a-patch" --author "Other Contributor <[email protected]>" && | ||
echo "b" >>baz.txt && | ||
stg new -rm "b-patch" --author "Other Contributor <[email protected]>" && | ||
echo "c" >>baz.txt && | ||
stg new -rm "c-patch" --author "Other Contributor <[email protected]>" && | ||
stg squash -m "abc-patch" --author "Override Author <[email protected]>" a-patch b-patch c-patch && | ||
test_when_finished "stg delete abc-patch" && | ||
stg show abc-patch | grep "Author:" >out && | ||
cat >expected <<-\EOF && | ||
Author: Override Author <[email protected]> | ||
EOF | ||
test_cmp expected out | ||
' | ||
|
||
test_expect_success 'Empty commit message aborts the squash' ' | ||
write_script fake-editor <<-\EOF && | ||
echo "" >"$1" | ||
|