MCPcopy
hub / github.com/go-git/go-git / TestCommitVerifyAlignment

Function TestCommitVerifyAlignment

tests/objectverify/commit_test.go:16–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestCommitVerifyAlignment(t *testing.T) {
17 t.Parallel()
18
19 if testing.Short() {
20 t.Skip("skipping commit verify")
21 }
22
23 if gpg == nil {
24 t.Error("gpg not available")
25 t.FailNow()
26 }
27
28 cases := []struct {
29 name string
30 // build returns the unsigned commit bytes that will be signed
31 // by gpg. The signature is injected as a single canonical
32 // "gpgsig" header in the standard location and the result is
33 // what both verifiers see, unless postSign rewrites it.
34 build func() []byte
35 // postSign optionally rewrites the signed object bytes (e.g.
36 // to inject a duplicated signature header). nil means use the
37 // standard injection path.
38 postSign func(signed []byte, sig string) []byte
39 }{
40 {
41 name: "valid",
42 build: func() []byte {
43 h, m := canonicalCommit()
44 return assembleCommit(h, m)
45 },
46 },
47 {
48 name: "duplicate-tree",
49 build: func() []byte {
50 h, m := canonicalCommit()
51 dup := append([]string{
52 h[0],
53 "tree 5555555555555555555555555555555555555555",
54 }, h[1:]...)
55 return assembleCommit(dup, m)
56 },
57 },
58 {
59 name: "duplicate-author",
60 build: func() []byte {
61 h, m := canonicalCommit()
62 dup := []string{
63 h[0],
64 h[1],
65 h[2],
66 "author Override Author <override@example.local> 1700000001 +0000",
67 h[3],
68 }
69 return assembleCommit(dup, m)
70 },
71 },
72 {
73 name: "duplicate-committer",

Callers

nothing calls this directly

Calls 14

canonicalCommitFunction · 0.85
assembleCommitFunction · 0.85
initRepoFunction · 0.85
gpgSignFunction · 0.85
injectGpgSigFunction · 0.85
writeLooseObjectFunction · 0.85
gitVerifyCommitFunction · 0.85
assertSameVerdictFunction · 0.85
combineErrFunction · 0.85
ShortMethod · 0.80
CommitObjectMethod · 0.80
SkipMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…