-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(init): resolve hooks path relative to repo root #1446
base: master
Are you sure you want to change the base?
Conversation
I'm not clear on which worktree |
3654225
to
5c0aa86
Compare
I agree with that interpretation of the docs: a relative hook path always needs to be interpreted from the worktree root that the hook is running in (which means that there's not a way to specify a hook path that's relative to the main worktree). |
5c0aa86
to
2b017e3
Compare
Allow running git commands in a different working directory in tests.
Ensure that `core.hooksPath` is resolved relative to the repository root of the current worktree, or the git dir if it is bare. This should be the same logic as git uses for resolution.
Since init previously used the root worktree for all of its actions, it failed to resolve `core.hooksPath` relative to the worktree it was being run in. Change `init` to work with the current worktree, and update code to explicitly refer to the shared git directory when necessary. This also entirely removes the need for `open_worktree_parent_repo`.
2b017e3
to
4d6d5fb
Compare
@@ -606,8 +606,7 @@ fn command_init( | |||
main_branch_name: Option<&str>, | |||
) -> EyreExitOr<()> { | |||
let mut in_ = BufReader::new(stdin()); | |||
let repo = Repo::from_current_dir()?; | |||
let mut repo = repo.open_worktree_parent_repo()?.unwrap_or(repo); | |||
let mut repo = Repo::from_current_dir()?; | |||
|
|||
let default_config = Config::open_default()?; | |||
let readonly_config = repo.get_readonly_config()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR changes readonly_config
to be read from the current worktree instead of the root. (It's used for modifying the root config to include branchless/config
) This doesn't seem to break any tests, and also uninstall
uses the current worktree instead of the root. I'm not sure if this is a problem or not, since I'm not clear on how much of the config file init/uninstall process is covered in the worktree tests.
Ensure that
core.hooksPath
is resolved relative to the repository root of the main worktree, or the git dir if it is bare (git itself uses the same logic for bare repos).Fixes #1438