Skip to content

Keep build versions accurate after Git changes and in source archives #4186

Description

@shiju-nv

User Story

I build OpenShell from linked worktrees and source archives. I need the binary to report the version of the source that produced it. Relevant Git changes should refresh that version, while unchanged inputs should reuse the previous build.

Problem Statement

#4947 merged on 2026-10-30 and fixed the ordinary linked-worktree problem where the .git pointer file led to missing watched paths and repeated no-op rebuilds. That original problem is resolved on current main.

This issue tracks the remaining cases in #3844:

  • Packed branch refs: when neither a loose branch ref nor logs/HEAD exists at the first build, watching only existing files can miss the loose ref created by the next branch update.
  • Reftable worktrees: Git can store refs in private and shared tables. Shared branch or release-tag changes must refresh the version even when HEAD stays unchanged.
  • Nested source archives: an archive without its own .git must use the package version, even when built inside another tagged repository.
  • Shallow history: changes to existing shallow-history metadata can affect commit distance or reachable release tags without moving HEAD.

Impact / Why This Matters

A binary can report a stale version or a version taken from an unrelated enclosing repository, making it harder to identify the source behind a deployment.

The fix must cover these remaining cases while preserving reuse of unchanged builds. The old warm-build timings describe the defect fixed by #4947; they do not measure this follow-up or show that ordinary warm builds are still broken.

Acceptance Criteria

  • Ordinary unchanged linked-worktree builds avoid the original missing-path invalidation (fix(core): resolve git rerun paths so worktree builds stay fresh #4947).
  • A packed-to-loose checked-out branch update refreshes the embedded version when neither its loose ref nor its HEAD reflog existed at the first build.
  • Linked reftable worktrees refresh after shared release-tag changes, including when HEAD stays fixed.
  • A source archive with no .git of its own uses the package version, whether standalone or nested inside another repository.
  • Existing shallow metadata changes are included among watched version inputs; unchanged inputs still reuse the previous build.
  • Existing release-version selection and protobuf generation are preserved.

Reproduction Steps

Use isolated fixture repositories rather than changing contributor tags or refs:

  1. For the packed-ref case, disable reflogs, pack the current branch, ensure its loose ref and HEAD reflog are absent, build, then move that branch without rewriting packed-refs. The next build must refresh the embedded SHA/version.
  2. For reftable, create a linked worktree with that backend, build, then add a release tag through the common repository while HEAD stays fixed. The next build must report the new tag.
  3. For archive ownership, place an unversioned source/probe archive inside a tagged repository. The archive must report its package version, not the parent's tag.

#3844 contains dependency-free Cargo probes using the production helper for these boundaries. Its packed-ref fixture disables reflogs and asserts that both the HEAD reflog and loose branch ref are absent before Cargo records its first inputs.

Suggested UX (if applicable)

No response

Environment

Logs

The existing nested-archive negative control selected 0.1.0 from the enclosing fixture repository when the archive expected its package version 9.8.7. The earlier six-test Cargo probe receipt covers the unchanged production helper. After strengthening the packed-ref precondition, both affected packed-ref/reftable tests pass. Running the packed-ref regression against current main's unchanged Git-watch helpers fails with a stale 0.1.0 after the branch advances; the follow-up refreshes the version. The original missing .git/HEAD warm-build log predates #4947 and is retained only as historical context.

Activity

  1. added theissue type on Oct 4, 2026
  2. github-actions commented on Oct 24, 2026

    @github-actions

    This issue has had no activity for 14 days and is now marked stale. It may be closed in 14 days if there is no further activity. Comment or remove the state:stale label to keep it open.

  3. changed the title [-]Unchanged openshell-core rebuilds on every cargo build in a linked git worktree[/-] [+]Complete Git version invalidation for packed refs, reftable, and nested archives[/+] on Oct 31, 2026
  4. added a commit that references this issue on Nov 2, 2026
    1bc6da6
  5. changed the title [-]Complete Git version invalidation for packed refs, reftable, and nested archives[/-] [+]Keep build versions accurate after Git changes and in source archives[/+] on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions