@@ -434,10 +434,8 @@ public TicketBranches listTicketBranches(SupportedProject project) {
434434 .filter (branch -> branch .isIssueBranch (project .getProject ().getTracker ()))//
435435 .collect (Collectors .toMap (Branch ::toString , branch -> branch ));
436436
437- Collection <Ticket > tickets = tracker .findTickets (project ,
438- ticketIds .keySet ().stream ()
439- .map (it -> TicketReference .ofTicket (it , TicketReference .Style .GitHub ))
440- .collect (Collectors .toList ()));
437+ Collection <Ticket > tickets = tracker .findTickets (project , ticketIds .keySet ().stream ()
438+ .map (it -> TicketReference .ofTicket (it , TicketReference .Style .GitHub )).collect (Collectors .toList ()));
441439
442440 return TicketBranches
443441 .from (tickets .stream ().collect (Collectors .toMap (ticket -> ticketIds .get (ticket .getId ()), ticket -> ticket )));
@@ -461,12 +459,17 @@ public TrainIteration getPreviousIteration(TrainIteration trainIteration) {
461459 return trainToUse .getIteration (Iteration .GA );
462460 }
463461
462+ Iteration iteration = trainIteration .getIteration ();
463+ Train train = trainIteration .getTrain ();
464+ if (iteration .isServiceIteration ()) {
465+ return train .getIteration (iteration .getPrevious ());
466+ }
467+
464468 SupportedProject build = trainIteration .getSupportedProject (Projects .BUILD );
465469
466470 Optional <TrainIteration > mostRecentBefore = getTags (build ) //
467- .filter ((tag , ti ) -> ti .getTrain ().equals (trainIteration .getTrain ())) //
468- .find ((tag , iteration ) -> iteration .getIteration ().compareTo (trainIteration .getIteration ()) < 0 ,
469- Pair ::getSecond );
471+ .filter ((tag , ti ) -> ti .getTrain ().equals (train )) //
472+ .find ((tag , ti ) -> ti .getIteration ().compareTo (trainIteration .getIteration ()) < 0 , Pair ::getSecond );
470473
471474 return mostRecentBefore .orElseThrow (() -> new IllegalStateException (
472475 "Cannot determine previous iteration for " + trainIteration .getReleaseTrainNameAndVersion ()));
@@ -482,7 +485,7 @@ public List<TicketReference> getTicketReferencesBetween(SupportedProject project
482485 Repository repo = git .getRepository ();
483486
484487 ModuleIteration toModuleIteration = to .getModule (project .getProject ());
485- ObjectId fromTag = resolveLowerBoundary (project .getProject (), from , tags , repo );
488+ ObjectId fromTag = resolveLowerBoundary (project .getStatus (), project . getProject (), from , tags , git , repo );
486489 ObjectId toTag = resolveUpperBoundary (toModuleIteration , tags , repo );
487490
488491 Iterable <RevCommit > commits = git .log ().addRange (fromTag , toTag ).call ();
@@ -517,15 +520,30 @@ public List<TicketReference> getTicketReferencesBetween(SupportedProject project
517520 return uniqueTicketReferences ;
518521 }
519522
520- protected ObjectId resolveLowerBoundary (Project project , TrainIteration iteration , VersionTags tags , Repository repo )
521- throws IOException {
523+ protected ObjectId resolveLowerBoundary (SupportStatus supportStatus , Project project , TrainIteration iteration ,
524+ VersionTags tags , Git git , Repository repo ) throws IOException , GitAPIException {
522525
523526 if (iteration .contains (project )) {
524527
525- Optional <Tag > fromTag = tags .filter (iteration .getTrain ()).findTag (iteration .getIteration ());
528+ Iteration it = iteration .getIteration ();
529+ Optional <Tag > fromTag = tags .filter (iteration .getTrain ()).findTag (it );
526530
527531 if (!fromTag .isPresent ()) {
528532
533+ // commercial releases might not have a previous tag as commercial releases are seeded without OSS tags.
534+ if (supportStatus == SupportStatus .COMMERCIAL && (it .isServiceIteration () || it .isGAIteration ())) {
535+
536+ Branch from = Branch .from (iteration .getModule (project ));
537+ Iterable <RevCommit > commits = git .log ().add (repo .resolve (from .toString ())).call ();
538+
539+ Optional <RevCommit > first = Streamable .of (commits ).stream ()
540+ .filter (rev -> rev .getFullMessage ().contains ("Seed " + from + " branch" )).findFirst ();
541+
542+ if (first .isPresent ()) {
543+ return first .get ();
544+ }
545+ }
546+
529547 // fall back to main
530548 return repo .parseCommit (repo .resolve (Branch .MAIN .toString ()));
531549 }
0 commit comments