Skip to content

ADFA-2591 Updating flox hooks for git worktree compatibility#863

Merged
hal-eisen-adfa merged 2 commits intostagefrom
ADFA-2591-Change-flox-hook-to-support-git-worktrees
Jan 22, 2026
Merged

ADFA-2591 Updating flox hooks for git worktree compatibility#863
hal-eisen-adfa merged 2 commits intostagefrom
ADFA-2591-Change-flox-hook-to-support-git-worktrees

Conversation

@hal-eisen-adfa
Copy link
Collaborator

Our current flox setup has two hooks: pre-commit and pre-push. We were assuming they could only be installed under the .git/ directory. Git worktrees convert the .git/ directory into a file of the same name. This breaks our old hook installation approach.

Git worktrees are helpful when working on multiple Jira tickets at the same time. Perhaps with an AI orchestration system like Gas Town.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Release Notes

Git Worktree Compatibility for Flox Hooks

Changes:

  • Updated flox hook installation in flox/local/.flox/env/manifest.toml to support git worktrees
  • Added validation check (git rev-parse --git-dir) to ensure a git repository exists before attempting hook installation
  • Replaced hardcoded .git/hooks path with dynamic computation using git rev-parse --git-common-dir
  • Added automatic creation of hooks directory with mkdir -p if it doesn't exist
  • Hooks (pre-commit and pre-push) now install correctly in both standard git repositories and git worktrees

Benefits:

  • Enables developers to use git worktrees for working on multiple Jira tickets simultaneously
  • More robust repository detection before attempting hook operations
  • Uses proper git APIs to locate hook installation path instead of assuming directory structure

Risks & Best Practices:

  • Hook functionality depends on .githooks/hook file existing at repository root (existing requirement, unchanged)
  • Silent error suppression on git commands: stderr is redirected to /dev/null, which may obscure genuine git errors in edge cases (though mitigated by the leading git repo existence check)
  • No explicit warning or logging if hook directory creation fails - relies on shell error semantics

Compatibility:

  • Maintains backward compatibility with standard repositories
  • Works with all supported systems: aarch64-darwin, aarch64-linux, x86_64-darwin, x86_64-linux

Walkthrough

The manifest.toml file's git hook installation logic is refactored to validate git repository status, dynamically compute the hooks directory path, and conditionally update hooks only when necessary or missing, replacing the previous hardcoded .git/hooks approach.

Changes

Cohort / File(s) Change Summary
Git Hook Installation Logic
flox/local/.flox/env/manifest.toml
Added git repository validation before hook installation; hook directory path now computed via git rev-parse --git-common-dir instead of hardcoded; hooks updated conditionally based on existence and marker presence; directory creation and permission handling preserved

Sequence Diagram

sequenceDiagram
    participant Manifest as Manifest Processor
    participant Git as Git System
    participant FS as Filesystem
    
    Manifest->>Git: Check if git repository exists<br/>(git rev-parse --git-dir)
    alt Git Repo Found
        Git-->>Manifest: Return success
        Manifest->>Git: Compute hooks directory<br/>(git rev-parse --git-common-dir)
        Git-->>Manifest: Return hooks_dir path
        Manifest->>FS: Create hooks directory
        FS-->>Manifest: Directory ready
        Manifest->>FS: Check pre-commit hook exists<br/>or lacks COGO_GIT_HOOK marker
        FS-->>Manifest: Hook status
        alt Hook Missing or Marker Absent
            Manifest->>FS: Write hook script
            FS-->>Manifest: Hook written
            Manifest->>FS: chmod +x hook file
            FS-->>Manifest: Permissions set
        end
        Manifest->>FS: Check pre-push hook exists<br/>or lacks COGO_GIT_HOOK marker
        FS-->>Manifest: Hook status
        alt Hook Missing or Marker Absent
            Manifest->>FS: Write hook script
            FS-->>Manifest: Hook written
            Manifest->>FS: chmod +x hook file
            FS-->>Manifest: Permissions set
        end
    else Not a Git Repo
        Git-->>Manifest: Return error
        Manifest->>Manifest: Skip hook installation
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hooks now check before they leap,
Git validation runs so deep,
Dynamic paths from git commands flow,
Conditionally they guard the show! 🪝✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies the main change: updating flox hooks to support git worktree compatibility, which aligns with the primary objective of the changeset.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation for the hook installation changes and the git worktree compatibility issue being addressed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hal-eisen-adfa hal-eisen-adfa requested a review from a team January 21, 2026 19:39
@jatezzz jatezzz self-requested a review January 22, 2026 13:56
@hal-eisen-adfa hal-eisen-adfa merged commit 8390409 into stage Jan 22, 2026
2 checks passed
@hal-eisen-adfa hal-eisen-adfa deleted the ADFA-2591-Change-flox-hook-to-support-git-worktrees branch January 22, 2026 16:40
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.

3 participants