Skip to content

Bug: Honor ignored files before checking version #2718

@sir4ur0n

Description

@sir4ur0n

Describe the bug
When using .ocamlformat-ignore to ignore a directory, ocamlformat still checks the version of .ocamlformat files in this directory and fails if it's different.

How to Reproduce
Steps to reproduce the behavior:
Have this file structure:

- .ocamlformat-ignore
- .ocamlformat
- vendor/.ocamlformat
- vendor/a.ml
# .ocamlformat-ignore
vendor/**
# .ocamlformat
version=0.26.2
# vendor/.ocamlformat
version=0.27.0

Running ocamlformat (e.g. with dune fmt) fails:

File "vendor/.formatted/_unknown_", line 1, characters 0-0:
ocamlformat: Error while parsing <root directory>/_build/.sandbox/6d68df527a037d3db3fd364e008232ac/default/vendor/.ocamlformat:
             Project should be formatted using ocamlformat version "0.27.0", but the installed version is "0.26.2"

I think the version check should only run on non-ignored directories.

Workaround

# .ocamlformat
version=0.26.2
version-check=false

But it no longer checks the ocamlformat version at the root either, which is not great.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions