phpro / grumphp

A PHP code-quality tool
MIT License
4.11k stars 430 forks source link

Fix retrieving git worktree path #1008

Open bart-jaskulski opened 2 years ago

bart-jaskulski commented 2 years ago
Q A
Branch master for features and deprecations
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Documented? no
Fixed tickets

@veewee Actually, I've made a bad assumption previously submitting PR (#1003) for git worktree path - git does store absolute path in .git file, but that's absolute path to the current worktree, while hooks are fired from common worktree root directory.

The hierarchy looks something like:

git-worktree
 > hooks
 > worktrees
   > worktree-1
      > commondir
   > worktree-2
      > commondir
worktree-1
  > .git
worktree-2
  > .git

With current patch, we are actually getting absolute path to worktree and reading the path from commondir file, which usually points up in hierarchy, to the root of git directory.

veewee commented 2 years ago

Thanks for reporting @bart-jaskulski.

Configured myself some worktrees locally to see what is going on exactly. Looks like this implementation works. I did add some minor comments to make it less confusing for future reference.

veewee commented 1 year ago

@bart-jaskulski Got any time to look at the comments I added above? Is there anything else I can do to get this merged?