@@ -362,5 +362,48 @@ def test_strip_trailing_asterisk_from_executables
362
362
assert_equal 'D' , diffs [ 1 ] . action
363
363
assert_equal 'arch' , diffs [ 1 ] . path
364
364
end
365
+
366
+ def test_committer_name_capture
367
+ name , email = BzrXmlParser . capture_name ( 'John' )
368
+ assert_equal name , 'John'
369
+ assert_equal email , nil
370
+ assert_equal [ 'John Doe' , nil ] , BzrXmlParser . capture_name ( 'John Doe' )
371
+ assert_equal [ 'John Doe jdoe@example.com' , nil ] , BzrXmlParser . capture_name ( 'John Doe jdoe@example.com' )
372
+ assert_equal [ 'John Doe <jdoe@example.com' , nil ] , BzrXmlParser . capture_name ( 'John Doe <jdoe@example.com' )
373
+ assert_equal [ 'John Doe jdoe@example.com>' , nil ] , BzrXmlParser . capture_name ( 'John Doe jdoe@example.com>' )
374
+ assert_equal [ 'John Doe' , 'jdoe@example.com' ] , BzrXmlParser . capture_name ( 'John Doe <jdoe@example.com>' )
375
+ assert_equal [ 'John Doe' , 'jdoe@example.com' ] , BzrXmlParser . capture_name ( 'John Doe <jdoe@example.com> ' )
376
+ assert_equal [ 'jdoe@example.com' , nil ] , BzrXmlParser . capture_name ( 'jdoe@example.com' )
377
+ xml = <<-XML
378
+ <logs>
379
+ <log>
380
+ <revno>15</revno>
381
+ <revisionid>a@b.com-20111013152207-q8uec9pp1330gfbh</revisionid>
382
+ <parents>
383
+ <parent>test@example.com-20111012195747-seei62z2wmefjhmo</parent>
384
+ </parents>
385
+ <committer>a@b.com</committer>
386
+ <authors>
387
+ <author>author@c.com</author>
388
+ </authors>
389
+ <branch-nick>myproject</branch-nick>
390
+ <timestamp>Thu 2011-10-13 11:22:07 -0400</timestamp>
391
+ <message><![CDATA[Updated with only email as committer name.]]></message>
392
+ <affected-files>
393
+ <modified>
394
+ <file fid="test3.txt-20110722163813-257mjqqrvw3mav0f-4">test_a.txt</file>
395
+ </modified>
396
+ </affected-files>
397
+ </log>
398
+ </logs>
399
+ XML
400
+ c = BzrXmlParser . parse ( xml ) . first
401
+ assert_equal 'M' , c . diffs . first . action
402
+ assert_equal 'test_a.txt' , c . diffs . first . path
403
+ assert_equal 'a@b.com' , c . committer_name
404
+ assert_equal nil , c . committer_email
405
+ assert_equal 'author@c.com' , c . author_name
406
+ assert_equal nil , c . author_email
407
+ end
365
408
end
366
409
end
0 commit comments