3 test_description
='signed push'
6 .
"$TEST_DIRECTORY"/lib-gpg.sh
10 test_create_repo dst
&&
12 git push dst master
:noop master
:ff master
:noff
15 test_expect_success setup
'
16 # master, ff and noff branches pointing at the same commit
18 git commit --allow-empty -m initial &&
20 git checkout -b noop &&
22 git checkout -b noff &&
24 # noop stays the same, ff advances, noff rewrites
26 git commit --allow-empty --amend -m rewritten &&
30 git commit --allow-empty -m second
33 test_expect_success
'unsigned push does not send push certificate' '
35 mkdir -p dst/.git/hooks &&
36 write_script dst/.git/hooks/post-receive <<-\EOF &&
37 if test -n "${GIT_PUSH_CERT-}"
39 git cat-file blob $GIT_PUSH_CERT >../push-cert
43 git push dst noop ff +noff &&
44 test -f dst/push-cert &&
45 ! test -s dst/push-cert
48 test_expect_success GPG
'signed push sends push certificate' '
50 mkdir -p dst/.git/hooks &&
51 write_script dst/.git/hooks/post-receive <<-\EOF &&
52 if test -n "${GIT_PUSH_CERT-}"
54 git cat-file blob $GIT_PUSH_CERT >../push-cert
57 cat >../push-cert-status <<E_O_F
58 SIGNER=${GIT_PUSH_CERT_SIGNER-nobody}
59 KEY=${GIT_PUSH_CERT_KEY-nokey}
60 STATUS=${GIT_PUSH_CERT_STATUS-nostatus}
65 cat >expect <<-\EOF &&
66 SIGNER=C O Mitter <committer@example.com>
71 git push --signed dst noop ff +noff &&
72 grep "$(git rev-parse noop ff) refs/heads/ff" dst/push-cert &&
73 grep "$(git rev-parse noop noff) refs/heads/noff" dst/push-cert &&
74 test_cmp expect dst/push-cert-status