3 # Copyright (c) 2020 Doan Tran Cong Danh
6 test_description
='test rebase --[no-]gpg-sign'
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
12 .
"$TEST_DIRECTORY/lib-rebase.sh"
13 .
"$TEST_DIRECTORY/lib-gpg.sh"
15 if ! test_have_prereq GPG
17 skip_all
='skip all test rebase --[no-]gpg-sign, gpg not available'
21 test_rebase_gpg_sign
() {
22 local must_fail
= will
=will fake_editor
=
25 must_fail
=test_must_fail
31 test_expect_success
"rebase $* with commit.gpgsign=$conf $will sign commit" "
33 git config commit.gpgsign $conf &&
35 FAKE_LINES='r 1 p 2' git rebase --force-rebase --root $* &&
36 $must_fail git verify-commit HEAD^ &&
37 $must_fail git verify-commit HEAD
41 test_expect_success
'setup' '
44 test_must_fail git verify-commit HEAD &&
45 test_must_fail git verify-commit HEAD^
48 test_expect_success
'setup: merge commit' '
49 test_commit fork-point &&
53 git merge --no-ff side &&
57 test_rebase_gpg_sign
! false
58 test_rebase_gpg_sign true
59 test_rebase_gpg_sign
! true
--no-gpg-sign
60 test_rebase_gpg_sign
! true
--gpg-sign --no-gpg-sign
61 test_rebase_gpg_sign false
--no-gpg-sign --gpg-sign
62 test_rebase_gpg_sign true
-i
63 test_rebase_gpg_sign
! true
-i --no-gpg-sign
64 test_rebase_gpg_sign
! true
-i --gpg-sign --no-gpg-sign
65 test_rebase_gpg_sign false
-i --no-gpg-sign --gpg-sign
67 test_expect_success
'rebase -r, merge strategy, --gpg-sign will sign commit' '
68 git reset --hard merged &&
69 test_unconfig commit.gpgsign &&
70 git rebase -fr --gpg-sign -s resolve --root &&
71 git verify-commit HEAD
74 test_expect_success
'rebase -r, merge strategy, commit.gpgsign=true will sign commit' '
75 git reset --hard merged &&
76 git config commit.gpgsign true &&
77 git rebase -fr -s resolve --root &&
78 git verify-commit HEAD
81 test_expect_success
'rebase -r, merge strategy, commit.gpgsign=false --gpg-sign will sign commit' '
82 git reset --hard merged &&
83 git config commit.gpgsign false &&
84 git rebase -fr --gpg-sign -s resolve --root &&
85 git verify-commit HEAD
88 test_expect_success
"rebase -r, merge strategy, commit.gpgsign=true --no-gpg-sign won't sign commit" '
89 git reset --hard merged &&
90 git config commit.gpgsign true &&
91 git rebase -fr --no-gpg-sign -s resolve --root &&
92 test_must_fail git verify-commit HEAD
95 test_expect_success
'rebase -r --gpg-sign will sign commit' '
96 git reset --hard merged &&
97 test_unconfig commit.gpgsign &&
98 git rebase -fr --gpg-sign --root &&
99 git verify-commit HEAD
102 test_expect_success
'rebase -r with commit.gpgsign=true will sign commit' '
103 git reset --hard merged &&
104 git config commit.gpgsign true &&
105 git rebase -fr --root &&
106 git verify-commit HEAD
109 test_expect_success
'rebase -r --gpg-sign with commit.gpgsign=false will sign commit' '
110 git reset --hard merged &&
111 git config commit.gpgsign false &&
112 git rebase -fr --gpg-sign --root &&
113 git verify-commit HEAD
116 test_expect_success
"rebase -r --no-gpg-sign with commit.gpgsign=true won't sign commit" '
117 git reset --hard merged &&
118 git config commit.gpgsign true &&
119 git rebase -fr --no-gpg-sign --root &&
120 test_must_fail git verify-commit HEAD