Repository navigation
[rush] Install Git hooks where Git reads them in linked worktrees - #6248
Open
Ultranmus (Ultranmus) wants to merge 1 commit into
Open
Ultranmus (Ultranmus) wants to merge 1 commit into
Ultranmus (Ultranmus) wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
This branch has not been deployed
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
When
rush installorrush updateruns in a linked Git worktree, Rush copiescommon/git-hooksinto the worktree's own Git folder (<common-git-dir>/worktrees/<name>/hooks). Git never reads hooks from there, so in that setup the hooks never run and commits skip them without any warning.Rush now installs the hooks in
<common-git-dir>/hooks, which is where Git reads them and whatgetIsHooksPathDefaultAsync()already treats as the default.Fixes #6246
Details
Git.getHooksFolder()returns thehooksfolder ofcommonGitDirinstead ofworktreeGitDir. In a normal clone the two are the same folder, so nothing changes there.rush install. It finds them fromgit rev-parse --show-toplevel, so each worktree runs its owncommon/git-hooksscripts, and removing the worktree that installed them doesn't silently disable the hooks for the others. The path from the repo root tocommon/git-hookscomes fromgetRepoRoot().How it was tested
getHooksFolder()in a linked worktree; it fails before the change.rush-liband ran its tests.Git,BaseInstallManager,PublishGitandInstallActionpass. TheTarExecutableandOperationBuildCacheDeferredWritestar tests fail on my macOS machine onmainas well.git -C bare worktree add ...), with the new wrapper inbare/hooks/pre-commit.git rev-parse --git-path hooksreturnsbare/hooks, and committing in each worktree (also from a subfolder) ran that worktree's owncommon/git-hooks/pre-commit.