diff options
Diffstat (limited to 't/t7513-interpret-trailers.sh')
-rwxr-xr-x | t/t7513-interpret-trailers.sh | 103 |
1 files changed, 101 insertions, 2 deletions
diff --git a/t/t7513-interpret-trailers.sh b/t/t7513-interpret-trailers.sh index 1efb88051a..aee785cffa 100755 --- a/t/t7513-interpret-trailers.sh +++ b/t/t7513-interpret-trailers.sh @@ -93,12 +93,39 @@ test_expect_success 'with config option on the command line' ' Acked-by: Johan Reviewed-by: Peff EOF - echo "Acked-by: Johan" | + { echo; echo "Acked-by: Johan"; } | git -c "trailer.Acked-by.ifexists=addifdifferent" interpret-trailers \ --trailer "Reviewed-by: Peff" --trailer "Acked-by: Johan" >actual && test_cmp expected actual ' +test_expect_success 'with only a title in the message' ' + cat >expected <<-\EOF && + area: change + + Reviewed-by: Peff + Acked-by: Johan + EOF + echo "area: change" | + git interpret-trailers --trailer "Reviewed-by: Peff" \ + --trailer "Acked-by: Johan" >actual && + test_cmp expected actual +' + +test_expect_success 'with multiline title in the message' ' + cat >expected <<-\EOF && + place of + code: change + + Reviewed-by: Peff + Acked-by: Johan + EOF + printf "%s\n" "place of" "code: change" | + git interpret-trailers --trailer "Reviewed-by: Peff" \ + --trailer "Acked-by: Johan" >actual && + test_cmp expected actual +' + test_expect_success 'with config setup' ' git config trailer.ack.key "Acked-by: " && cat >expected <<-\EOF && @@ -213,7 +240,7 @@ test_expect_success 'with 2 files arguments' ' ' test_expect_success 'with message that has comments' ' - cat basic_message >>message_with_comments && + cat basic_message >message_with_comments && sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF && # comment @@ -232,12 +259,44 @@ test_expect_success 'with message that has comments' ' Reviewed-by: Johan Cc: Peff + # last comment + EOF cat basic_patch >>expected && git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual && test_cmp expected actual ' +test_expect_success 'with message that has an old style conflict block' ' + cat basic_message >message_with_comments && + sed -e "s/ Z\$/ /" >>message_with_comments <<-\EOF && + # comment + + # other comment + Cc: Z + # yet another comment + Reviewed-by: Johan + Reviewed-by: Z + # last comment + + Conflicts: + + EOF + cat basic_message >expected && + cat >>expected <<-\EOF && + # comment + + Reviewed-by: Johan + Cc: Peff + # last comment + + Conflicts: + + EOF + git interpret-trailers --trim-empty --trailer "Cc: Peff" message_with_comments >actual && + test_cmp expected actual +' + test_expect_success 'with commit complex message and trailer args' ' cat complex_message_body >expected && sed -e "s/ Z\$/ /" >>expected <<-\EOF && @@ -267,6 +326,46 @@ test_expect_success 'with complex patch, args and --trim-empty' ' test_cmp expected actual ' +test_expect_success 'in-place editing with basic patch' ' + cat basic_message >message && + cat basic_patch >>message && + cat basic_message >expected && + echo >>expected && + cat basic_patch >>expected && + git interpret-trailers --in-place message && + test_cmp expected message +' + +test_expect_success 'in-place editing with additional trailer' ' + cat basic_message >message && + cat basic_patch >>message && + cat basic_message >expected && + echo >>expected && + cat >>expected <<-\EOF && + Reviewed-by: Alice + EOF + cat basic_patch >>expected && + git interpret-trailers --trailer "Reviewed-by: Alice" --in-place message && + test_cmp expected message +' + +test_expect_success 'in-place editing on stdin disallowed' ' + test_must_fail git interpret-trailers --trailer "Reviewed-by: Alice" --in-place < basic_message +' + +test_expect_success 'in-place editing on non-existing file' ' + test_must_fail git interpret-trailers --trailer "Reviewed-by: Alice" --in-place nonexisting && + test_path_is_missing nonexisting +' + +test_expect_success POSIXPERM,SANITY "in-place editing doesn't clobber original file on error" ' + cat basic_message >message && + chmod -r message && + test_must_fail git interpret-trailers --trailer "Reviewed-by: Alice" --in-place message && + chmod +r message && + test_cmp message basic_message +' + test_expect_success 'using "where = before"' ' git config trailer.bug.where "before" && cat complex_message_body >expected && |