Repository navigation
feat(bash): markdownlint-cli2 shim uses the commit gate's config - #458
Merged
Merged
Conversation
markdownlint-cli2 reads config only from its cwd and below, never from a parent dir or ~. In a repo with no config of its own, a bare run lints under markdownlint's defaults (MD013 on, and more), while the commit gate and standards-check use the canonical config. An agent ran the bare binary, saw findings the gate never reports, and acted on them. New ~/.local/bin/markdownlint-cli2 shim (bash/markdownlint-cli2- wrapper.sh, linked by install.sh like gh and gpush). With no --config and no repo config in the cwd, it prepends --config <canonical>. Otherwise it runs the real binary unchanged, and warns when the canonical file is missing. It finds the real binary by realpath, skipping itself, and exits 127 if there is none. The repo config filename list moves to git/hooks/lib-markdownlint- config.sh, which lint-markdown.sh and the shim both source. Tests: - test-markdownlint-cli2-shim.sh: argv-recording stub; each case fails against a passthrough, always-prepend, or path-string self-skip shim. - test-markdownlint-config-drift.sh: the canonical config equals github-workflows' standards/markdownlint.json (jq -S), and the filename list matches run-standards.sh's order. Fails, never skips, when no upstream copy is reachable. CI points it at the clone bash-tests.yml already makes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
markdownlint-cli2 reads config only from its cwd and below. It never reads a parent dir or
~. In a repo with no config of its own, a baremarkdownlint-cli2 file.mdlints under markdownlint's defaults (MD013 on, and more). The commit gate and standards-check use the canonical config instead. An agent ran the bare binary, saw findings the gate never reports, and acted on them.What
Shim
bash/markdownlint-cli2-wrapper.sh, installed as~/.local/bin/markdownlint-cli2. install.sh section 4 links it the same way it links gh and gpush:~/.local/bin/markdownlint-cli2 -> ~/.config/bash/markdownlint-cli2-wrapper.sh. The gitignore and the symlink exclusions need no change, becausebash/is already allow-listed and a known config dir.--help: run the real binary unchanged.--config Xor--config=X: unchanged.${MARKDOWNLINT_CANONICAL_CONFIG:-~/.config/markdownlint-cli/.markdownlint.json}): prepend--config <canonical>.The real binary is the first one on PATH whose realpath is not the shim. If there is none, the shim exits 127. If a second copy of the shim calls this one again, it exits 126.
One list.
git/hooks/lib-markdownlint-config.shholds the config filename list. lint-markdown.sh and the shim both source it, each from beside its own realpath, so a pull works beforeinstall.sh --sync.run-standards.shin github-workflows keeps its own copy, and the drift test checks its order.CI. bash-tests.yml points the drift test at the github-workflows clone it already makes for yamllint (
MARKDOWNLINT_UPSTREAM_DIR).After install
Run
hash -rin each open shell, or open a new one. Bash caches the old/opt/homebrew/bin/markdownlint-cli2path, so until then a plainmarkdownlint-cli2skips the shim.which markdownlint-cli2shows the PATH result;hash -t markdownlint-cli2shows the cached one.Tests
bash/tests/test-markdownlint-cli2-shim.shuses a stub "real" binary that records argv. Cases: no config gets canonical added;.markdownlint-cli2.jsonc,.markdownlint.jsonand.markdownlintrcleave args unchanged;--config Xand--config=Xleave args unchanged; a missing canonical leaves args unchanged and prints a notice; no args and--helppass through; self-skip with the shim dir on PATH twice plus a second symlink dir; no real binary exits 127.Known-bad runs (
MDL_SHIM=<bad shim>):--configbash/tests/test-markdownlint-config-drift.sh:standards/markdownlint.json(jq -S).for c in ...order.Upstream source, in order:
MARKDOWNLINT_UPSTREAM_DIR, then~/Developer/github-workflows(may be stale), then raw.githubusercontent.com. If none works, the test fails; it never skips.Known-bad runs: MD013 flipped in the upstream copy fails check 1. Two list entries swapped fails check 2. A list copy appended to the shim fails check 3. A bad explicit
MARKDOWNLINT_UPSTREAM_DIRfails. No sibling clone with the network blocked fails.Local run:
run-tests.sh markdowngives 5/5 (the three existing lint-markdown tests plus the two new ones). The symlink-exclusions and install tests pass.The mirror test is smartwatermelon/github-workflows#202.