Skip to content

Commit

Permalink
fix: ignoring promotion rules
Browse files Browse the repository at this point in the history
Bug #4401 was `(promote until-clean)` rules being incorrectly ignored by
`--ignore-promoted-rules`. PR #5956 fixed it but only made the fix
available to newer projects.

This means that projects must update their dune versions before users
can actually build this project without being affected by this bug.
Since this bug fix doesn't have much the potential to break anything, we
make the fix available to all versions.

Signed-off-by: Rudi Grinberg <[email protected]>

<!-- ps-id: 82b639c6-a417-4ae8-8cd2-fae02849ea83 -->
  • Loading branch information
rgrinberg committed Aug 26, 2023
1 parent e2d1d96 commit a952a77
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/dune_rules/dune_file.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2464,19 +2464,16 @@ type t =
}

let is_promoted_rule =
let is_promoted_mode version = function
let is_promoted_mode = function
| Rule.Mode.Promote { only = None; lifetime; _ } ->
if version >= (3, 5)
then (
match lifetime with
| Unlimited -> true
| Until_clean -> false)
else true
(match lifetime with
| Unlimited -> true
| Until_clean -> false)
| _ -> false
in
fun version rule ->
fun rule ->
match rule with
| Rule { mode; _ } | Menhir_stanza.T { mode; _ } -> is_promoted_mode version mode
| Rule { mode; _ } | Menhir_stanza.T { mode; _ } -> is_promoted_mode mode
| _ -> false
;;

Expand All @@ -2485,9 +2482,7 @@ let parse sexps ~dir ~file ~project =
let+ stanzas = Stanzas.parse ~file ~dir project sexps in
let stanzas =
if !Clflags.ignore_promoted_rules
then (
let version = Dune_project.dune_version project in
List.filter stanzas ~f:(fun s -> not (is_promoted_rule version s)))
then List.filter stanzas ~f:(fun s -> not (is_promoted_rule s))
else stanzas
in
{ dir; project; stanzas }
Expand Down

0 comments on commit a952a77

Please sign in to comment.