]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3435-rebase-gpg-sign.sh
Merge branch 'pb/ci-matrix-wo-shortcut'
[thirdparty/git.git] / t / t3435-rebase-gpg-sign.sh
CommitLineData
c241371c
ĐTCD
1#!/bin/sh
2#
3# Copyright (c) 2020 Doan Tran Cong Danh
4#
5
6test_description='test rebase --[no-]gpg-sign'
7
d1c02d93 8GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
9export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
c241371c
ĐTCD
11. ./test-lib.sh
12. "$TEST_DIRECTORY/lib-rebase.sh"
13. "$TEST_DIRECTORY/lib-gpg.sh"
14
15if ! test_have_prereq GPG
16then
17 skip_all='skip all test rebase --[no-]gpg-sign, gpg not available'
18 test_done
19fi
20
21test_rebase_gpg_sign () {
22 local must_fail= will=will fake_editor=
23 if test "x$1" = "x!"
24 then
25 must_fail=test_must_fail
26 will="won't"
27 shift
28 fi
29 conf=$1
30 shift
31 test_expect_success "rebase $* with commit.gpgsign=$conf $will sign commit" "
32 git reset two &&
33 git config commit.gpgsign $conf &&
34 set_fake_editor &&
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
38 "
39}
40
41test_expect_success 'setup' '
42 test_commit one &&
43 test_commit two &&
44 test_must_fail git verify-commit HEAD &&
45 test_must_fail git verify-commit HEAD^
46'
47
48test_expect_success 'setup: merge commit' '
49 test_commit fork-point &&
50 git switch -c side &&
51 test_commit three &&
d1c02d93 52 git switch main &&
c241371c
ĐTCD
53 git merge --no-ff side &&
54 git tag merged
55'
56
57test_rebase_gpg_sign ! false
58test_rebase_gpg_sign true
59test_rebase_gpg_sign ! true --no-gpg-sign
60test_rebase_gpg_sign ! true --gpg-sign --no-gpg-sign
61test_rebase_gpg_sign false --no-gpg-sign --gpg-sign
62test_rebase_gpg_sign true -i
63test_rebase_gpg_sign ! true -i --no-gpg-sign
64test_rebase_gpg_sign ! true -i --gpg-sign --no-gpg-sign
65test_rebase_gpg_sign false -i --no-gpg-sign --gpg-sign
66
67test_expect_failure 'rebase -p --no-gpg-sign override commit.gpgsign' '
68 git reset --hard merged &&
69 git config commit.gpgsign true &&
d1c02d93 70 git rebase -p --no-gpg-sign --onto=one fork-point main &&
c241371c
ĐTCD
71 test_must_fail git verify-commit HEAD
72'
73
ae03c97a
74test_expect_success 'rebase -r, merge strategy, --gpg-sign will sign commit' '
75 git reset --hard merged &&
76 test_unconfig commit.gpgsign &&
77 git rebase -fr --gpg-sign -s resolve --root &&
78 git verify-commit HEAD
79'
80
81test_expect_success 'rebase -r, merge strategy, commit.gpgsign=true will sign commit' '
82 git reset --hard merged &&
83 git config commit.gpgsign true &&
84 git rebase -fr -s resolve --root &&
85 git verify-commit HEAD
86'
87
88test_expect_success 'rebase -r, merge strategy, commit.gpgsign=false --gpg-sign will sign commit' '
89 git reset --hard merged &&
90 git config commit.gpgsign false &&
91 git rebase -fr --gpg-sign -s resolve --root &&
92 git verify-commit HEAD
93'
94
19dad040
95test_expect_success "rebase -r, merge strategy, commit.gpgsign=true --no-gpg-sign won't sign commit" '
96 git reset --hard merged &&
97 git config commit.gpgsign true &&
98 git rebase -fr --no-gpg-sign -s resolve --root &&
99 test_must_fail git verify-commit HEAD
100'
101
43ad4f2e
102test_expect_success 'rebase -r --gpg-sign will sign commit' '
103 git reset --hard merged &&
104 test_unconfig commit.gpgsign &&
105 git rebase -fr --gpg-sign --root &&
106 git verify-commit HEAD
107'
108
109test_expect_success 'rebase -r with commit.gpgsign=true will sign commit' '
110 git reset --hard merged &&
111 git config commit.gpgsign true &&
112 git rebase -fr --root &&
113 git verify-commit HEAD
114'
115
116test_expect_success 'rebase -r --gpg-sign with commit.gpgsign=false will sign commit' '
117 git reset --hard merged &&
118 git config commit.gpgsign false &&
119 git rebase -fr --gpg-sign --root &&
120 git verify-commit HEAD
121'
122
123test_expect_success "rebase -r --no-gpg-sign with commit.gpgsign=true won't sign commit" '
124 git reset --hard merged &&
125 git config commit.gpgsign true &&
126 git rebase -fr --no-gpg-sign --root &&
127 test_must_fail git verify-commit HEAD
128'
129
c241371c 130test_done