| 242 | } |
| 243 | |
| 244 | func (s *SuiteCommit) TestCommitEncodeDecodeIdempotent(c *C) { |
| 245 | pgpsignature := `-----BEGIN PGP SIGNATURE----- |
| 246 | |
| 247 | iQEcBAABAgAGBQJTZbQlAAoJEF0+sviABDDrZbQH/09PfE51KPVPlanr6q1v4/Ut |
| 248 | LQxfojUWiLQdg2ESJItkcuweYg+kc3HCyFejeDIBw9dpXt00rY26p05qrpnG+85b |
| 249 | hM1/PswpPLuBSr+oCIDj5GMC2r2iEKsfv2fJbNW8iWAXVLoWZRF8B0MfqX/YTMbm |
| 250 | ecorc4iXzQu7tupRihslbNkfvfciMnSDeSvzCpWAHl7h8Wj6hhqePmLm9lAYqnKp |
| 251 | 8S5B/1SSQuEAjRZgI4IexpZoeKGVDptPHxLLS38fozsyi0QyDyzEgJxcJQVMXxVi |
| 252 | RUysgqjcpT8+iQM1PblGfHR4XAhuOqN5Fx06PSaFZhqvWFezJ28/CLyX5q+oIVk= |
| 253 | =EFTF |
| 254 | -----END PGP SIGNATURE----- |
| 255 | ` |
| 256 | |
| 257 | tag := fmt.Sprintf(`object f000000000000000000000000000000000000000 |
| 258 | type commit |
| 259 | tag change |
| 260 | tagger Foo <foo@example.local> 1695827841 -0400 |
| 261 | |
| 262 | change |
| 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 | }, |