lint: upgrade lint scripts for worktrees #34391

pull willcl-ark wants to merge 1 commits into bitcoin:master from willcl-ark:lint-worktrees changing 4 files +93 −59
  1. willcl-ark commented at 1:42 pm on January 23, 2026: member

    Fixes #29972

    Use a single script to run the linter locally or in CI.

    Works from inside a worktree.

  2. DrahtBot added the label Tests on Jan 23, 2026
  3. DrahtBot commented at 1:43 pm on January 23, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34391.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK davidgumberg

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  4. in test/lint/README.md:16 in 887635d073
    13+```
    14+
    15+Or use the included Dockerfile:
    16 
    17 ```sh
    18 DOCKER_BUILDKIT=1 docker build --platform=linux --tag=bitcoin-linter --file="./ci/lint_imagefile" ./ && docker run --rm -v $(pwd):/bitcoin -it bitcoin-linter
    


    maflcko commented at 1:50 pm on January 23, 2026:
    It seems a bit lengthy, and if the python script is basically calling the same command, maybe this line can be removed from the docs?

    willcl-ark commented at 11:28 am on January 25, 2026:
    Removed in a3c44cd2762ce1464bf2ec7abe4e2d0fd539b834
  5. in ci/lint.py:35 in 887635d073
    30+    if not content.startswith("gitdir: "):
    31+        return []
    32+    gitdir = (repo_root / content.removeprefix("gitdir: ")).resolve()
    33+    main_gitdir = gitdir.parent.parent
    34+    return [
    35+        f"--volume={gitdir}:{gitdir}:ro",
    


    davidgumberg commented at 0:16 am on January 24, 2026:
    0        f"--volume={gitdir}:{gitdir}",
    

    otherwise:

    0fatal: Unable to create '/btc/bitcoin/.git/worktrees/34391/index.lock': Read-only file system 
    

    alternatively, could get rid gitdir and just mount main_gitdir (without ro ):

     0diff --git a/ci/lint.py b/ci/lint.py
     1index ed522c6e90..eff624ce8e 100755
     2--- a/ci/lint.py
     3+++ b/ci/lint.py
     4@@ -25,16 +25,12 @@ def run(cmd, **kwargs):
     5 def get_worktree_mounts(repo_root):
     6     git_path = repo_root / ".git"
     7     if not git_path.is_file():
     8-        return []
     9+        return ""
    10     content = git_path.read_text().strip()
    11     if not content.startswith("gitdir: "):
    12-        return []
    13-    gitdir = (repo_root / content.removeprefix("gitdir: ")).resolve()
    14-    main_gitdir = gitdir.parent.parent
    15-    return [
    16-        f"--volume={gitdir}:{gitdir}:ro",
    17-        f"--volume={main_gitdir}:{main_gitdir}:ro",
    18-    ]
    19+        return ""
    20+    gitdir = (repo_root / content.removeprefix("gitdir: ")).resolve().parent.parent
    21+    return f"--volume={gitdir}:{gitdir}"
    22
    23
    24 def main():
    25@@ -71,7 +67,7 @@ def main():
    26             "--rm",
    27             *extra_env,
    28             f"--volume={repo_root}:/bitcoin",
    29-            *get_worktree_mounts(repo_root),
    30+            get_worktree_mounts(repo_root),
    31             *([] if is_ci else ["-it"]),
    32             container,
    33             *sys.argv[1:],
    

    but this is slightly less belt and suspenders I guess, no strong feelings about that.


    willcl-ark commented at 11:28 am on January 25, 2026:
    Thanks, removed the ro from gitdir in a3c44cd2762ce1464bf2ec7abe4e2d0fd539b834
  6. in ci/lint.py:77 in 887635d073 outdated
    72+            *extra_env,
    73+            f"--volume={repo_root}:/bitcoin",
    74+            *get_worktree_mounts(repo_root),
    75+            *([] if is_ci else ["-it"]),
    76+            container,
    77+            *sys.argv[1:],
    


    davidgumberg commented at 0:27 am on January 24, 2026:

    Would be nice to add a note documenting this in the README

    e.g. just mentioning that you can do:

    0./ci/lint.py ./test/lint/lint-python.py
    

    not blocking at all, feel free to disregard


    willcl-ark commented at 11:28 am on January 25, 2026:

    Also taken in a3c44cd2762ce1464bf2ec7abe4e2d0fd539b834.

    Thanks for the review!

  7. davidgumberg commented at 0:31 am on January 24, 2026: contributor
    Thanks for improving this, so much nicer than the docker command, and it works in worktrees. Because worktrees don’t work right, I have been doing cargo run, but I have run into a mismatch with the CI linter doing that.
  8. lint: upgrade lint scripts for worktrees
    Add a ci/lint.py script to run the linter both locally or inside the CI
    (replacing .github/ci-lint-exec.py) which supports running from a
    worktree.
    
    Determines whether we are in a worktree, and mounts the real `.git`
    directory as a read-only volume if we are.
    a3c44cd276
  9. willcl-ark force-pushed on Jan 25, 2026
  10. in test/lint/README.md:19 in a3c44cd276
    17+
    18+```sh
    19+./ci/lint.py ./test/lint/lint-python.py
    20 ```
    21 
    22 Building the container can be done every time, because it is fast when the
    


    davidgumberg commented at 10:01 pm on January 25, 2026:
    Non-blocking documentation nit: this line and below could probably be dropped.
  11. davidgumberg commented at 10:01 pm on January 25, 2026: contributor

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-01-27 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me