@@ -480,9 +480,29 @@ struct
480480 flat_all_unapplied_matches))
481481 | Tjc.Job.Type_. (Plan { tag_query = _; kind = Some (Tjc.Job.Type_.Kind. Drift _) })
482482 ->
483- (* In the case that it is a plan for drift, then plan all layers in one go. *)
483+ (* In the case that it is a plan for drift, then plan all
484+ layers in one go. We match against [all_matches]
485+ because in the case of planning drift, we explicitly do
486+ not care if any dirspace is considered applied.
487+
488+ Consider this scenario:
489+
490+ 1. Drift run against [main], find no drift.
491+
492+ 2. Nobody merges anything to [main].
493+
494+ 3. Drift runs again. It runs nothing.
495+
496+ The reason (3) happens is because we consider all
497+ dirspaces in [main] as "applied" because their plans
498+ came back with no changes. This is what we would do in
499+ a PR flow, but not what we want to do in a drift flow.
500+ There could be drift between (1) and (2). So we ignore
501+ anything considered "applied" in (3) and run everything
502+ again.
503+ *)
484504 CCList. filter (Terrat_change_match3. match_tag_query ~tag_query )
485- @@ CCList. flatten all_unapplied_matches
505+ @@ CCList. flatten all_matches
486506 | Tjc.Job.Type_. Autoplan
487507 | Tjc.Job.Type_. Plan _
488508 | Tjc.Job.Type_. Gate_approval _
0 commit comments