зеркало из https://github.com/microsoft/git.git
trailer: add tests for commands in config file
And add a few other tests for some special cases. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
85039fb6e4
Коммит
b9384ff34e
|
@ -735,4 +735,129 @@ test_expect_success 'default "where" is now "after"' '
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'with simple command' '
|
||||||
|
git config trailer.sign.key "Signed-off-by: " &&
|
||||||
|
git config trailer.sign.where "after" &&
|
||||||
|
git config trailer.sign.ifExists "addIfDifferentNeighbor" &&
|
||||||
|
git config trailer.sign.command "echo \"A U Thor <author@example.com>\"" &&
|
||||||
|
cat complex_message_body >expected &&
|
||||||
|
sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
|
||||||
|
Fixes: Z
|
||||||
|
Acked-by= Z
|
||||||
|
Reviewed-by:
|
||||||
|
Signed-off-by: Z
|
||||||
|
Signed-off-by: A U Thor <author@example.com>
|
||||||
|
EOF
|
||||||
|
git interpret-trailers --trailer "review:" --trailer "fix=22" \
|
||||||
|
<complex_message >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'with command using commiter information' '
|
||||||
|
git config trailer.sign.ifExists "addIfDifferent" &&
|
||||||
|
git config trailer.sign.command "echo \"\$GIT_COMMITTER_NAME <\$GIT_COMMITTER_EMAIL>\"" &&
|
||||||
|
cat complex_message_body >expected &&
|
||||||
|
sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
|
||||||
|
Fixes: Z
|
||||||
|
Acked-by= Z
|
||||||
|
Reviewed-by:
|
||||||
|
Signed-off-by: Z
|
||||||
|
Signed-off-by: C O Mitter <committer@example.com>
|
||||||
|
EOF
|
||||||
|
git interpret-trailers --trailer "review:" --trailer "fix=22" \
|
||||||
|
<complex_message >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'with command using author information' '
|
||||||
|
git config trailer.sign.key "Signed-off-by: " &&
|
||||||
|
git config trailer.sign.where "after" &&
|
||||||
|
git config trailer.sign.ifExists "addIfDifferentNeighbor" &&
|
||||||
|
git config trailer.sign.command "echo \"\$GIT_AUTHOR_NAME <\$GIT_AUTHOR_EMAIL>\"" &&
|
||||||
|
cat complex_message_body >expected &&
|
||||||
|
sed -e "s/ Z\$/ /" >>expected <<-\EOF &&
|
||||||
|
Fixes: Z
|
||||||
|
Acked-by= Z
|
||||||
|
Reviewed-by:
|
||||||
|
Signed-off-by: Z
|
||||||
|
Signed-off-by: A U Thor <author@example.com>
|
||||||
|
EOF
|
||||||
|
git interpret-trailers --trailer "review:" --trailer "fix=22" \
|
||||||
|
<complex_message >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'setup a commit' '
|
||||||
|
echo "Content of the first commit." > a.txt &&
|
||||||
|
git add a.txt &&
|
||||||
|
git commit -m "Add file a.txt"
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'with command using $ARG' '
|
||||||
|
git config trailer.fix.ifExists "replace" &&
|
||||||
|
git config trailer.fix.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG" &&
|
||||||
|
FIXED=$(git log -1 --oneline --format="%h (%s)" --abbrev-commit --abbrev=14 HEAD) &&
|
||||||
|
cat complex_message_body >expected &&
|
||||||
|
sed -e "s/ Z\$/ /" >>expected <<-EOF &&
|
||||||
|
Fixes: $FIXED
|
||||||
|
Acked-by= Z
|
||||||
|
Reviewed-by:
|
||||||
|
Signed-off-by: Z
|
||||||
|
Signed-off-by: A U Thor <author@example.com>
|
||||||
|
EOF
|
||||||
|
git interpret-trailers --trailer "review:" --trailer "fix=HEAD" \
|
||||||
|
<complex_message >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'with failing command using $ARG' '
|
||||||
|
git config trailer.fix.ifExists "replace" &&
|
||||||
|
git config trailer.fix.command "false \$ARG" &&
|
||||||
|
cat complex_message_body >expected &&
|
||||||
|
sed -e "s/ Z\$/ /" >>expected <<-EOF &&
|
||||||
|
Fixes: Z
|
||||||
|
Acked-by= Z
|
||||||
|
Reviewed-by:
|
||||||
|
Signed-off-by: Z
|
||||||
|
Signed-off-by: A U Thor <author@example.com>
|
||||||
|
EOF
|
||||||
|
git interpret-trailers --trailer "review:" --trailer "fix=HEAD" \
|
||||||
|
<complex_message >actual &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'with empty tokens' '
|
||||||
|
git config --unset trailer.fix.command &&
|
||||||
|
cat >expected <<-EOF &&
|
||||||
|
|
||||||
|
Signed-off-by: A U Thor <author@example.com>
|
||||||
|
EOF
|
||||||
|
git interpret-trailers --trailer ":" --trailer ":test" >actual <<-EOF &&
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'with command but no key' '
|
||||||
|
git config --unset trailer.sign.key &&
|
||||||
|
cat >expected <<-EOF &&
|
||||||
|
|
||||||
|
sign: A U Thor <author@example.com>
|
||||||
|
EOF
|
||||||
|
git interpret-trailers >actual <<-EOF &&
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'with no command and no key' '
|
||||||
|
git config --unset trailer.review.key &&
|
||||||
|
cat >expected <<-EOF &&
|
||||||
|
|
||||||
|
review: Junio
|
||||||
|
sign: A U Thor <author@example.com>
|
||||||
|
EOF
|
||||||
|
git interpret-trailers --trailer "review:Junio" >actual <<-EOF &&
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче