237 | 237 |
strings.Split(hdr.V, "\n"))
|
238 | 238 |
}
|
239 | 239 |
|
|
240 |
func TestCommitDecodingMessageWithLineStartingWithTree(t *testing.T) {
|
|
241 |
from := new(bytes.Buffer)
|
|
242 |
|
|
243 |
// The tricky part here that we're testing is the "tree support" in the
|
|
244 |
// `mergetag` header, which we should not try to parse as a tree header.
|
|
245 |
// Note also that this entry contains trailing whitespace which must not
|
|
246 |
// be trimmed.
|
|
247 |
fmt.Fprintf(from, `tree e8ad84c41c2acde27c77fa212b8865cd3acfe6fb
|
|
248 |
parent b343c8beec664ef6f0e9964d3001c7c7966331ae
|
|
249 |
parent 1e8a52e18cfb381bc9cc1f0b720540364d2a6edd
|
|
250 |
author Pat Doe <pdoe@example.org> 1337892984 -0700
|
|
251 |
committer Pat Doe <pdoe@example.org> 1337892984 -0700
|
|
252 |
mergetag object 1e8a52e18cfb381bc9cc1f0b720540364d2a6edd
|
|
253 |
type commit
|
|
254 |
tag random
|
|
255 |
tagger J. Roe <jroe@example.ca> 1337889148 -0600
|
|
256 |
|
|
257 |
Random changes
|
|
258 |
|
|
259 |
This text contains some
|
|
260 |
tree support code.
|
|
261 |
-----BEGIN PGP SIGNATURE-----
|
|
262 |
Version: GnuPG v1.4.11 (GNU/Linux)
|
|
263 |
|
|
264 |
Not a real signature
|
|
265 |
-----END PGP SIGNATURE-----
|
|
266 |
|
|
267 |
Merge tag 'random' of git://git.example.ca/git/
|
|
268 |
`)
|
|
269 |
|
|
270 |
flen := from.Len()
|
|
271 |
|
|
272 |
commit := new(Commit)
|
|
273 |
n, err := commit.Decode(sha1.New(), from, int64(flen))
|
|
274 |
|
|
275 |
require.Nil(t, err)
|
|
276 |
require.Equal(t, flen, n)
|
|
277 |
require.Equal(t, commit.ExtraHeaders, []*ExtraHeader{
|
|
278 |
{
|
|
279 |
K: "mergetag",
|
|
280 |
V: `object 1e8a52e18cfb381bc9cc1f0b720540364d2a6edd
|
|
281 |
type commit
|
|
282 |
tag random
|
|
283 |
tagger J. Roe <jroe@example.ca> 1337889148 -0600
|
|
284 |
|
|
285 |
Random changes
|
|
286 |
|
|
287 |
This text contains some
|
|
288 |
tree support code.
|
|
289 |
-----BEGIN PGP SIGNATURE-----
|
|
290 |
Version: GnuPG v1.4.11 (GNU/Linux)
|
|
291 |
|
|
292 |
Not a real signature
|
|
293 |
-----END PGP SIGNATURE-----`},
|
|
294 |
},
|
|
295 |
)
|
|
296 |
require.Equal(t, commit.Message, "Merge tag 'random' of git://git.example.ca/git/")
|
|
297 |
}
|
|
298 |
|
240 | 299 |
func assertLine(t *testing.T, buf *bytes.Buffer, wanted string, args ...interface{}) {
|
241 | 300 |
got, err := buf.ReadString('\n')
|
242 | 301 |
if err == io.EOF {
|