Repository navigation
fix(targethasher): only hash local FILE lines in bzlmod repo markers - #330
Merged
Merged
Conversation
readMarkerHash hashed every non-ENV marker line. Some FILE: lines point at files generated during a repo's fetch (e.g. go_repository_cache's go.env and the binaries built by go_repository_tools) and embed the Bazel output_base path. The output_base is derived from the workspace path, so the collapsed hash of every file in such a repo differed between two computes done in different workspaces, flagging the repo and all of its reverse dependencies as changed even though no dependency changed. Hash only the first line (the repo rule's declarative inputs) and FILE: lines for main-repo files (@@// labels, which cover patches). ENV:, REPO_MAPPING: and FILE: lines for other repos are skipped. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
yushan8
marked this pull request as draft
October 8, 2026 23:16
Bazel records a repo rule's file-system inputs as KIND:@@<repo>//<path>, with FILE, DIRTREE and DIRENTS kinds. Only FILE:@@// lines were treated as local to the main repo, so a checked-in directory input (e.g. a patches directory) would not have affected the marker hash. Treat all three kinds with an @@// path as local. Inputs in other repos and absolute-path inputs stay excluded. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
yushan8
marked this pull request as ready for review
October 9, 2026 00:13
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
yushan8
marked this pull request as draft
October 9, 2026 00:23
xytan0056
approved these changes
Oct 9, 2026
yushan8
marked this pull request as ready for review
October 9, 2026 03:14
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
Summary
Why?
Some of the skipped
FILE:lines are generated during the fetch (gazelle's go.env and the gazelle and fetch_repo binaries) and contain the Bazel output_base path, which depends on the workspace location. The same commit computed in two different workspaces got different hashes, so the whole repo and everything depending on it showed up as changed.What?
Now it only hashes the first line of the marker (the repo rule's inputs) plus the inputs that live in the main repo (FILE:, DIRTREE:, DIRENTS: with an @@// path, which covers patches). Everything else is skipped: ENV:, REPO_MAPPING:, inputs from other repos, and absolute paths. Patch edits and version, URL or integrity changes still change the hash.
The marker file hashing is only supported since bazel doesn't support
bazel mod show_repo --all_reposuntil later versions, and internally the repo is on bazel 8.1.1 with bzlmod.On Bazel below 8.6.0, markers are how we hash these repos, one hash per repo rather than per file. Hashing external repos via
bazel mod show_repo --all_reposwill be supported in follow up PRs.Test Plan
New markers_test.go covers the cases above, bazel test //core/targethasher:targethasher_test passes, and on two checkouts of the same commit in different directories none of the 28 real markers differ anymore.
Test Plan
Unit test
Tested on internal monorepo to ensure the external hash did not differ across revisions
Issues