| 198 | } |
| 199 | |
| 200 | func (s *SuiteCommit) TestCommitEncodeDecodeIdempotent(c *C) { |
| 201 | pgpsignature := `-----BEGIN PGP SIGNATURE----- |
| 202 | |
| 203 | iQEcBAABAgAGBQJTZbQlAAoJEF0+sviABDDrZbQH/09PfE51KPVPlanr6q1v4/Ut |
| 204 | LQxfojUWiLQdg2ESJItkcuweYg+kc3HCyFejeDIBw9dpXt00rY26p05qrpnG+85b |
| 205 | hM1/PswpPLuBSr+oCIDj5GMC2r2iEKsfv2fJbNW8iWAXVLoWZRF8B0MfqX/YTMbm |
| 206 | ecorc4iXzQu7tupRihslbNkfvfciMnSDeSvzCpWAHl7h8Wj6hhqePmLm9lAYqnKp |
| 207 | 8S5B/1SSQuEAjRZgI4IexpZoeKGVDptPHxLLS38fozsyi0QyDyzEgJxcJQVMXxVi |
| 208 | RUysgqjcpT8+iQM1PblGfHR4XAhuOqN5Fx06PSaFZhqvWFezJ28/CLyX5q+oIVk= |
| 209 | =EFTF |
| 210 | -----END PGP SIGNATURE----- |
| 211 | ` |
| 212 | |
| 213 | tag := fmt.Sprintf(`object f000000000000000000000000000000000000000 |
| 214 | type commit |
| 215 | tag change |
| 216 | tagger Foo <foo@example.local> 1695827841 -0400 |
| 217 | |
| 218 | change |
| 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 | }, |