MCPcopy Create free account
hub / github.com/go-git/go-git / TestCommitEncodeDecodeIdempotent

Method TestCommitEncodeDecodeIdempotent

plumbing/object/commit_test.go:200–282  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

198}
199
200func (s *SuiteCommit) TestCommitEncodeDecodeIdempotent(c *C) {
201 pgpsignature := `-----BEGIN PGP SIGNATURE-----
202
203iQEcBAABAgAGBQJTZbQlAAoJEF0+sviABDDrZbQH/09PfE51KPVPlanr6q1v4/Ut
204LQxfojUWiLQdg2ESJItkcuweYg+kc3HCyFejeDIBw9dpXt00rY26p05qrpnG+85b
205hM1/PswpPLuBSr+oCIDj5GMC2r2iEKsfv2fJbNW8iWAXVLoWZRF8B0MfqX/YTMbm
206ecorc4iXzQu7tupRihslbNkfvfciMnSDeSvzCpWAHl7h8Wj6hhqePmLm9lAYqnKp
2078S5B/1SSQuEAjRZgI4IexpZoeKGVDptPHxLLS38fozsyi0QyDyzEgJxcJQVMXxVi
208RUysgqjcpT8+iQM1PblGfHR4XAhuOqN5Fx06PSaFZhqvWFezJ28/CLyX5q+oIVk=
209=EFTF
210-----END PGP SIGNATURE-----
211`
212
213 tag := fmt.Sprintf(`object f000000000000000000000000000000000000000
214type commit
215tag change
216tagger Foo <foo@example.local> 1695827841 -0400
217
218change
219%s
220`, pgpsignature)
221
222 ts, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05-07:00")
223 c.Assert(err, IsNil)
224 commits := []*Commit{
225 {
226 Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
227 Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts},
228 Message: "Message\n\nFoo\nBar\nWith trailing blank lines\n\n",
229 TreeHash: plumbing.NewHash("f000000000000000000000000000000000000001"),
230 ParentHashes: []plumbing.Hash{plumbing.NewHash("f000000000000000000000000000000000000002")},
231 Encoding: defaultUtf8CommitMessageEncoding,
232 },
233 {
234 Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
235 Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts},
236 Message: "Message\n\nFoo\nBar\nWith no trailing blank lines",
237 TreeHash: plumbing.NewHash("0000000000000000000000000000000000000003"),
238 ParentHashes: []plumbing.Hash{
239 plumbing.NewHash("f000000000000000000000000000000000000004"),
240 plumbing.NewHash("f000000000000000000000000000000000000005"),
241 plumbing.NewHash("f000000000000000000000000000000000000006"),
242 plumbing.NewHash("f000000000000000000000000000000000000007"),
243 },
244 Encoding: MessageEncoding("ISO-8859-1"),
245 },
246 {
247 Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
248 Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts},
249 Message: "Testing mergetag\n\nHere, commit is not signed",
250 TreeHash: plumbing.NewHash("f000000000000000000000000000000000000001"),
251 ParentHashes: []plumbing.Hash{
252 plumbing.NewHash("f000000000000000000000000000000000000002"),
253 plumbing.NewHash("f000000000000000000000000000000000000003"),
254 },
255 MergeTag: tag,
256 Encoding: defaultUtf8CommitMessageEncoding,
257 },

Callers

nothing calls this directly

Calls 6

DecodeMethod · 0.95
HashMethod · 0.95
NewHashFunction · 0.92
MessageEncodingTypeAlias · 0.85
EncodeMethod · 0.65
ParseMethod · 0.45

Tested by

no test coverage detected