@@ -606,7 +606,7 @@ public void CanRewriteParents()
606
606
Assert . True ( hasBeenCalled ) ;
607
607
}
608
608
609
- // Graft the orphan "test" branch to the tip of "packed"
609
+ // Graft the orphan "test" branch to the rewritten tip of "packed"
610
610
//
611
611
// Before:
612
612
// * e90810b (test, tag: lw, tag: e90810b, tag: test)
@@ -623,7 +623,7 @@ public void CanRewriteParents()
623
623
// |
624
624
// * 0c25efa
625
625
// | <------------------ add this link
626
- // * 41bc8c6 (packed)
626
+ // * 107e13b (packed) <-- to this rewritten commit
627
627
// |
628
628
// * 5001298
629
629
[ Fact ]
@@ -638,32 +638,48 @@ public void CanRewriteParentWithRewrittenCommit()
638
638
{
639
639
OnError = OnError ,
640
640
OnSucceeding = OnSucceeding ,
641
+ CommitHeaderRewriter =
642
+ c =>
643
+ {
644
+ if ( c . Id == newParent . Id )
645
+ {
646
+ return CommitRewriteInfo . From ( c , message : "changed" ) ;
647
+ }
648
+
649
+ return null ;
650
+ } ,
641
651
CommitParentsRewriter =
642
652
c =>
643
- c . Id != commitToRewrite . Id
644
- ? c . Parents
645
- : new [ ] { newParent }
646
- } , commitToRewrite ) ;
653
+ {
654
+ if ( c . Id == commitToRewrite . Id )
655
+ {
656
+ return new [ ] { newParent } ;
657
+ }
658
+
659
+ return c . Parents ;
660
+ } ,
661
+ } , commitToRewrite , newParent ) ;
647
662
648
663
AssertSucceedingButNotError ( ) ;
649
664
650
- // Assert "packed" hasn't been rewritten
651
- Assert . True ( repo . Branches [ "packed" ] . Tip . Sha . StartsWith ( "41bc8c6" ) ) ;
665
+ // Assert "packed" has been rewritten
666
+ var newPackedCommit = repo . Branches [ "packed" ] . Tip ;
667
+ Assert . True ( newPackedCommit . Sha . StartsWith ( "107e13b" ) ) ;
652
668
653
669
// Assert (test, tag: lw, tag: e90810b, tag: test) have been rewritten
654
670
var rewrittenTestCommit = repo . Branches [ "test" ] . Tip ;
655
- Assert . True ( rewrittenTestCommit . Sha . StartsWith ( "f558880" ) ) ;
671
+ Assert . True ( rewrittenTestCommit . Sha . StartsWith ( "f558880" ) ) ; // TODO: This SHA should change
656
672
Assert . Equal ( rewrittenTestCommit , repo . Lookup < Commit > ( "refs/tags/lw^{commit}" ) ) ;
657
673
Assert . Equal ( rewrittenTestCommit , repo . Lookup < Commit > ( "refs/tags/e90810b^{commit}" ) ) ;
658
674
Assert . Equal ( rewrittenTestCommit , repo . Lookup < Commit > ( "refs/tags/test^{commit}" ) ) ;
659
675
660
676
// Assert parent of rewritten commit
661
677
var rewrittenTestCommitParent = rewrittenTestCommit . Parents . Single ( ) ;
662
- Assert . True ( rewrittenTestCommitParent . Sha . StartsWith ( "0c25efa" ) ) ;
678
+ Assert . True ( rewrittenTestCommitParent . Sha . StartsWith ( "0c25efa" ) ) ; // TODO: This SHA should change
663
679
664
680
// Assert grand parent of rewritten commit
665
681
var rewrittenTestCommitGrandParent = rewrittenTestCommitParent . Parents . Single ( ) ;
666
- Assert . True ( rewrittenTestCommitGrandParent . Sha . StartsWith ( "41bc8c6" ) ) ;
682
+ Assert . Equal ( newPackedCommit , rewrittenTestCommitGrandParent ) ;
667
683
}
668
684
669
685
[ Fact ]
0 commit comments