Skip to content

Fix git hooks in worktrees#4859

Open
alexh-tigera wants to merge 2 commits into
tigera:masterfrom
alexh-tigera:fix-git-hooks-in-worktrees
Open

Fix git hooks in worktrees#4859
alexh-tigera wants to merge 2 commits into
tigera:masterfrom
alexh-tigera:fix-git-hooks-in-worktrees

Conversation

@alexh-tigera
Copy link
Copy Markdown
Member

Description

Allow git hooks to work when the operator repo is a worktree.

Release Note

TBD

For PR author

  • [ ] Tests for change.
  • [ ] If changing pkg/apis/, run make gen-files
  • [ ] If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables git hooks and make pre-commit to function correctly when the operator repo is checked out as a git worktree (where .git is a file pointing elsewhere rather than a directory).

Changes:

  • install-git-hooks now uses git rev-parse --git-common-dir to locate the hooks directory and creates it if missing, supporting both regular and worktree checkouts.
  • Makefile computes GIT_COMMON_DIR from git rev-parse --git-common-dir, mounts it into the container when it lives outside CURDIR/.git, and uses it to read objects/info/alternates.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
install-git-hooks Install hooks into the common git dir (handles worktrees) and create the hooks dir if absent.
Makefile Add GIT_COMMON_DIR + WORKTREE_GIT_MOUNT and use them in the pre-commit target so the containerized hook can access git metadata in worktrees.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants