Skip to content

fix: keep mise task headers as directives, and keep the suite off an inherited GIT_DIR - #68

Merged
P4suta merged 2 commits into
mainfrom
fix/mise-task-directives
Sep 24, 2026
Merged

P4suta merged 2 commits into
mainfrom
fix/mise-task-directives

Conversation

@P4suta

@P4suta P4suta commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Two fixes, one for the tool and one for its test suite, found together.

mise file-task headers are directives

mise reads a file task's configuration from #MISE … and #USAGE … comment lines (also //, and the [MISE]/[USAGE] spellings).
ocomment read them as prose, so fix --tidy under wrap = "sentence" joined them — #MISE description=… and #USAGE flag "--fix-stale-hooks" … became one # MISE description=… USAGE flag … line, which mise parses as a single MISE header and the flag disappears.
This happened to a real task in a dotfiles repository through the machine-wide pre-commit gate.

  • A cross-language, case-sensitive match on the raw comment: # or //, optional whitespace, then MISE, [MISE], USAGE or [USAGE] at a word boundary.
    # mise installs … and // Usage: … stay prose.
  • Load-bearing: removing one changes what the task runs or which arguments it accepts.
  • Rust and the OCaml reference both, with the spec catalogue, check_directives.py samples and near-misses, generated docs, the fuzz pool, three fixtures and Rust tests.

The test suite no longer follows an inherited GIT_DIR

Git exports GIT_DIR and its neighbours to hooks, and pre-push runs cargo xtask preflight.
Pushing this branch from a linked worktree let the CLI suite's git init -q reinitialise the shared git directory, which left the main checkout with core.bare = true.
With GIT_DIR pointed at another repository, ocomment check --staged inside the suite followed it as well and hung.

  • tests/common::isolated builds every git and ocomment process the suites start, without any inherited GIT_* variable.
  • xtask removes the git rev-parse --local-env-vars names from every preflight step as an outer layer.
  • The binary is unchanged; inside a hook it must honour GIT_DIR.
  • a_repository_named_by_the_callers_environment_is_left_alone reruns a repository-building test with GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE aimed at a sentinel and requires its config to be byte-identical; it fails with the filter disabled.

Verified

  • cargo xtask preflight: 30 of 30 steps, including the Rust/OCaml differential.
  • The whole ocomment test suite with GIT_DIR aimed at a sentinel repository: passes in seconds, sentinel config unchanged (before: hung for over 20 minutes).
  • The original git-audit header passes check, and fix --tidy leaves it byte-identical.
  • This branch was pushed from a linked worktree through the pre-push preflight, and the main checkout kept core.bare = false.

Found, not fixed here

  • a_rewrite_moves_only_white_space (proptest) fails on ////\x0b on main as well.
  • fuzz_differential.py --seed 1 reports Rust/OCaml divergences on @license legal markers and one C++ raw-string case, on main as well.

mise and its usage library read a file task's configuration from comments at the head of the script: `#` or `//`, optional whitespace, then `MISE` or `USAGE`, bare or in square brackets, matched case-sensitively on the raw line.
These were read as prose, so `ocomment fix --tidy` under `wrap = "sentence"` joined a `#MISE` line and the `#USAGE flag` line under it into one `# MISE` line, and the task stopped declaring the flag.

Both implementations now recognise the header in every language, from the raw bytes, and file it in the load-bearing tier: `#MISE depends=` and `dir=` decide what runs and `#USAGE flag` declares an argument, so removing one changes the task rather than a report about it.
As a directive it also ends a paragraph, so the reflow no longer joins it or writes a space after its `#`.
`# mise installs the runtime`, `# Usage: audit` and `#MISEish` stay prose.

The spec lists both names under `load_bearing` and names them in no `[load_bearing_by_language]` entry, for the reason the cross-language tool markers are absent from `[protected_by_language]`.
Three fixtures pin the removal protection in shell and JavaScript and the header a dotfiles repository wrote surviving a sentence wrap byte for byte.
…ames

Git exports GIT_DIR and its neighbours to a hook, and the pre-push hook runs `cargo xtask preflight`.
Every step inherited them, so from a linked worktree the CLI suite's `git init -q` in a temporary directory reinitialised the shared git directory and left the main checkout with `core.bare = true`.
Run the same suite with GIT_DIR pointed anywhere and the ocomment binary it drives follows it too: `check --staged` asked that repository for its index and hung.

The suite now builds every git and ocomment process through one helper, `tests/common::isolated`, which drops every inherited `GIT_*` variable.
xtask also removes the names `git rev-parse --local-env-vars` lists from every preflight step, so a step that is not a test is kept off the pushed repository too.
The binary itself is unchanged: it runs inside hooks and has to honour GIT_DIR.

`a_repository_named_by_the_callers_environment_is_left_alone` reruns a repository-building test with GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE pointed at a sentinel repository and requires the sentinel's config to be byte-identical afterwards.
With the helper's filter disabled it fails; with it, it passes.
@coderabbitai

coderabbitai Bot commented Sep 24, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e861ccc9-1f09-4a21-9449-28dd792d2357


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@P4suta
P4suta enabled auto-merge (squash) September 24, 2026 04:56
@P4suta
P4suta merged commit 94eb331 into main Sep 24, 2026
20 checks passed
@P4suta
P4suta deleted the fix/mise-task-directives branch September 24, 2026 05:00
@github-actions github-actions Bot mentioned this pull request Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant