MCPcopy Index your code
hub / github.com/go-git/go-git / TestCommitEncodeDecodeIdempotent

Method TestCommitEncodeDecodeIdempotent

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

Source from the content-addressed store, hash-verified

242}
243
244func (s *SuiteCommit) TestCommitEncodeDecodeIdempotent(c *C) {
245 pgpsignature := `-----BEGIN PGP SIGNATURE-----
246
247iQEcBAABAgAGBQJTZbQlAAoJEF0+sviABDDrZbQH/09PfE51KPVPlanr6q1v4/Ut
248LQxfojUWiLQdg2ESJItkcuweYg+kc3HCyFejeDIBw9dpXt00rY26p05qrpnG+85b
249hM1/PswpPLuBSr+oCIDj5GMC2r2iEKsfv2fJbNW8iWAXVLoWZRF8B0MfqX/YTMbm
250ecorc4iXzQu7tupRihslbNkfvfciMnSDeSvzCpWAHl7h8Wj6hhqePmLm9lAYqnKp
2518S5B/1SSQuEAjRZgI4IexpZoeKGVDptPHxLLS38fozsyi0QyDyzEgJxcJQVMXxVi
252RUysgqjcpT8+iQM1PblGfHR4XAhuOqN5Fx06PSaFZhqvWFezJ28/CLyX5q+oIVk=
253=EFTF
254-----END PGP SIGNATURE-----
255`
256
257 tag := fmt.Sprintf(`object f000000000000000000000000000000000000000
258type commit
259tag change
260tagger Foo <foo@example.local> 1695827841 -0400
261
262change
263%s
264`, pgpsignature)
265
266 ts, err := time.Parse(time.RFC3339, "2006-01-02T15:04:05-07:00")
267 c.Assert(err, IsNil)
268 commits := []*Commit{
269 {
270 Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
271 Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts},
272 Message: "Message\n\nFoo\nBar\nWith trailing blank lines\n\n",
273 TreeHash: plumbing.NewHash("f000000000000000000000000000000000000001"),
274 ParentHashes: []plumbing.Hash{plumbing.NewHash("f000000000000000000000000000000000000002")},
275 Encoding: defaultUtf8CommitMessageEncoding,
276 },
277 {
278 Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
279 Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts},
280 Message: "Message\n\nFoo\nBar\nWith no trailing blank lines",
281 TreeHash: plumbing.NewHash("0000000000000000000000000000000000000003"),
282 ParentHashes: []plumbing.Hash{
283 plumbing.NewHash("f000000000000000000000000000000000000004"),
284 plumbing.NewHash("f000000000000000000000000000000000000005"),
285 plumbing.NewHash("f000000000000000000000000000000000000006"),
286 plumbing.NewHash("f000000000000000000000000000000000000007"),
287 },
288 Encoding: MessageEncoding("ISO-8859-1"),
289 },
290 {
291 Author: Signature{Name: "Foo", Email: "foo@example.local", When: ts},
292 Committer: Signature{Name: "Bar", Email: "bar@example.local", When: ts},
293 Message: "Testing mergetag\n\nHere, commit is not signed",
294 TreeHash: plumbing.NewHash("f000000000000000000000000000000000000001"),
295 ParentHashes: []plumbing.Hash{
296 plumbing.NewHash("f000000000000000000000000000000000000002"),
297 plumbing.NewHash("f000000000000000000000000000000000000003"),
298 },
299 MergeTag: tag,
300 Encoding: defaultUtf8CommitMessageEncoding,
301 },

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