diff mbox series

[v3,2/2] t7501: add tests for --amend --signoff

Message ID 20240110163622.51182-6-shyamthakkar001@gmail.com (mailing list archive)
State New, archived
Headers show
Series t7501: add tests for --include, --only, | expand

Commit Message

Ghanshyam Thakkar Jan. 10, 2024, 4:35 p.m. UTC
Add tests for amending the commit to add Signed-off-by trailer. And
also to check if it does not add another trailer if one already exists.

Currently, there are tests for --signoff separately in t7501, however,
they are not tested with --amend.

Therefore, these tests belong with other similar tests of --amend in
t7501-commit-basic-functionality.

Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>
---
 t/t7501-commit-basic-functionality.sh | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

Comments

Phillip Wood Jan. 11, 2024, 4:30 p.m. UTC | #1
On 10/01/2024 16:35, Ghanshyam Thakkar wrote:
> Add tests for amending the commit to add Signed-off-by trailer. And
> also to check if it does not add another trailer if one already exists.
> 
> Currently, there are tests for --signoff separately in t7501, however,
> they are not tested with --amend.
> 
> Therefore, these tests belong with other similar tests of --amend in
> t7501-commit-basic-functionality.
> 
> Signed-off-by: Ghanshyam Thakkar <shyamthakkar001@gmail.com>

This version looks good, thanks for re-rolling. I have left one comment 
below but it is not worth re-rolling just for that.

> +test_expect_success 'amend commit to add signoff' '
> +
> +	test_commit "msg" file content &&
> +	git commit --amend --signoff &&
> +	test_commit_message HEAD <<-EOF
> +	msg
> +
> +	Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
> +	EOF
> +
> +'

If you do happen re-roll I think we could happily lose the empty line 
before the closing "'" in this test and the next.

Best Wishes

Phillip
diff mbox series

Patch

diff --git a/t/t7501-commit-basic-functionality.sh b/t/t7501-commit-basic-functionality.sh
index e005175d0b..546d60d7fc 100755
--- a/t/t7501-commit-basic-functionality.sh
+++ b/t/t7501-commit-basic-functionality.sh
@@ -3,8 +3,7 @@ 
 # Copyright (c) 2007 Kristian Høgsberg <krh@redhat.com>
 #
 
-# fixme: test the various index usages, test reflog,
-# signoff
+# fixme: test the various index usages, test reflog
 
 test_description='git commit'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
@@ -430,6 +429,30 @@  test_expect_success 'amend commit to fix date' '
 
 '
 
+test_expect_success 'amend commit to add signoff' '
+
+	test_commit "msg" file content &&
+	git commit --amend --signoff &&
+	test_commit_message HEAD <<-EOF
+	msg
+
+	Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+	EOF
+
+'
+
+test_expect_success 'amend does not add signoff if it already exists' '
+
+	test_commit --signoff "tenor" file newcontent &&
+	git commit --amend --signoff &&
+	test_commit_message HEAD <<-EOF
+	tenor
+
+	Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
+	EOF
+
+'
+
 test_expect_success 'commit mentions forced date in output' '
 	git commit --amend --date=2010-01-02T03:04:05 >output &&
 	grep "Date: *Sat Jan 2 03:04:05 2010" output