@@ -58,6 +58,7 @@ private static IEnumerable<TaggedVersion> SelectWhereSemver(
58
58
if ( head is null )
59
59
return ( 1 , null ) ;
60
60
61
+ // Stryker disable once all: used for logging only
61
62
return await FromCommit (
62
63
commit : head . Value ,
63
64
commitDescriptor : "HEAD" ,
@@ -103,7 +104,9 @@ public FromCommitOptions(
103
104
{
104
105
var ( current , height , rootDescriptor , heightSinceBranch ) = toVisit . Pop ( ) ;
105
106
107
+ // Stryker disable all: used for logging only
106
108
var descriptor = heightSinceBranch == 0 ? rootDescriptor : $ "{ rootDescriptor } ~{ heightSinceBranch } ";
109
+ // Stryker restore all
107
110
108
111
// already visited in an ultimately prior parent
109
112
if ( ! visited . Add ( current ) )
@@ -156,17 +159,23 @@ public FromCommitOptions(
156
159
}
157
160
else
158
161
{
159
- for ( int i = parents . Count ; i -- > 0 ; )
162
+ // commits to visit must be added in the reverse order, so the earlier parents are visited first
163
+ for ( int i = parents . Count ; i -- > 0 ; )
160
164
{
161
- if ( i == 0 )
162
- toVisit . Push ( ( parents [ i ] , height + 1 , rootDescriptor , heightSinceBranch + 1 ) ) ;
163
- else
164
- toVisit . Push ( ( parents [ i ] , height + 1 , $ "{ rootDescriptor } ^{ i + 1 } ", 0 ) ) ;
165
+ var parent = parents [ i ] ;
166
+ var parentHeight = height + 1 ;
167
+ // Stryker disable all: used for logging only
168
+ var isDiverging = i == 0 ;
169
+ var parentDescriptor = isDiverging ? $ "{ rootDescriptor } ^{ i + 1 } " : rootDescriptor ;
170
+ var parentHeightSinceBranch = isDiverging ? 0 : heightSinceBranch + 1 ;
171
+ // Stryker restore all
172
+
173
+ toVisit . Push ( ( parents [ i ] , height + 1 , parentDescriptor , parentHeightSinceBranch ) ) ;
165
174
}
166
175
}
167
176
}
168
177
169
- Debug . Assert ( candidates . Count > 0 ) ;
178
+ Debug . Assert ( candidates . Count != 0 ) ;
170
179
171
180
return candidates
172
181
. OrderByDescending ( x => x . version is not null )
0 commit comments