Skip to content

fix(core): resolve git metadata in worktrees#2475

Draft
matthewgrossman wants to merge 1 commit into
mainfrom
test-compilation-new-worktree
Draft

fix(core): resolve git metadata in worktrees#2475
matthewgrossman wants to merge 1 commit into
mainfrom
test-compilation-new-worktree

Conversation

@matthewgrossman

Copy link
Copy Markdown
Contributor

Summary

Prevent no-change builds in linked Git worktrees from repeatedly rebuilding openshell-core and its downstream crates. The core build script currently watches paths under ../../.git, but .git is a file in a linked worktree, so Cargo sees the requested metadata paths as missing and reruns the build script on every invocation.

This PR resolves the real Git metadata paths before emitting Cargo change directives. It fixes repeated builds within an existing linked worktree; improving cache reuse for the first build in a different worktree remains a separate follow-up.

Related Issue

None.

Changes

  • Resolve HEAD and refs/tags through git rev-parse --git-path instead of assuming .git is a directory.
  • Emit cargo:rerun-if-changed only for Git metadata paths that actually exist.
  • Preserve packaged and container builds where Git metadata is unavailable.
  • Add coverage for normal repositories, linked worktrees, and source trees without Git metadata.

Testing

  • mise run pre-commit passes
  • cargo test -p openshell-core passes (338 unit tests and 3 new integration tests)
  • cargo clippy -p openshell-core --all-targets -- -D warnings passes
  • Fresh linked-worktree workspace benchmark: an immediate no-change build took 47.3 seconds on current main and rebuilt 19 workspace crates; this branch took 8.35 seconds and compiled none
  • E2E tests not applicable; this only changes build-script invalidation

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs not applicable; no runtime architecture or user-facing behavior changes

Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

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