Skip to content
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

Use correct path to .git/COMMIT_EDITMSG when using non-standard .git dir location #461

Conversation

pascal-hofmann
Copy link
Contributor

Q A
Branch master
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Documented? no
Fixed tickets -

When grumphp is used with a .git dir in a non-standard location the commit-msg hook may look for the .git/COMMIT_EDITMSG file in the wrong location.

This PR prefixes the path with git_dir configured in grumphp.yml if it's a relative path, so the correct path is used in all cases.

Note: The path supplied to the hook by git may be absolute. In this case there is no need to fix it. This happens when grumphp is used inside a git submodule.

@veewee
Copy link
Contributor

veewee commented Feb 7, 2018

Hi @pascal-hofmann,

Thanks for the PR.

Can you give me steps to reproduce this issue?
The git hook is passing the commit message file directly to grumphp, so this shouldn't be an issue.

See:
https://github.com/phpro/grumphp/blob/master/resources/hooks/local/commit-msg#L10

@pascal-hofmann
Copy link
Contributor Author

Yep, but the path may be relative and directory is changed, so the relative path is incorrect afterwards. Will post steps/versions required to reproduce.

@pascal-hofmann
Copy link
Contributor Author

pascal-hofmann commented Feb 7, 2018

Steps / versions to reproduce:

phpro/grumphp (v0.13.1)
git version 2.15.1

mkdir issue461/
cd issue461/
git init
mkdir app
cd app
echo -e "parameters:\n    git_dir: .." >grumphp.yml
composer require --dev phpro/grumphp
git add composer.json composer.lock grumphp.yml
git commit -m 'Added grumphp'

Result for me is this error message on red background:

SplFileInfo::openFile(.git/COMMIT_EDITMSG): failed to open stream: No such
file or directory

This happens, because the path passed to the hook is .git/COMMIT_EDITMSG. The current working directory is issue461/app so grumphp wants to open issue461/app/.git/COMMIT_EDITMSG instead of issue461/.git/COMMIT_EDITMSG.

My PR fixes this.

@pascal-hofmann
Copy link
Contributor Author

pascal-hofmann commented Mar 2, 2018

This PR has now been open for nearly 4 weeks. How can I help to get this merged?

@ddebasilio
Copy link

This is happening to me too, can this get merged ?

@Landerstraeten Landerstraeten added this to the Version 0.14.1 milestone Mar 30, 2018
@Landerstraeten Landerstraeten merged commit 140f0ba into phpro:master Mar 30, 2018
@pascalhofmann
Copy link

Thanks for merging! 👍

@pascal-hofmann pascal-hofmann deleted the use_correct_path_to_commit_msg_file branch April 3, 2018 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants