phpro / grumphp

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

[FEATURE] Post-Merge Hook #181

Closed Kanti closed 7 years ago

Kanti commented 8 years ago
Q A
Branch master
Bug? no
New feature? yes
Question? yes/no
Documentation? no
Related tickets

How about another git hook. A post-merge hook. We Idea is simple.

#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com

# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.

changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

check_run() {
    echo "$changed_files" | grep --quiet "$1" && eval "$2"
}

# Example usage
# In this example it's used to run `npm install` if package.json changed
check_run package.json "npm install"
check_run bower.json "bower install"
check_run composer.json "composer install"
check_run composer.lock "composer install"

@from https://gist.github.com/sindresorhus/7996717

We could make it configurable in the grumphp.yml file.

veewee commented 8 years ago

I am not sure I am in favour of this feature request. It sure looks pretty handy, but we are trying to us GrumPHP as a quality tool. Not just some git hook task runner.

Maybe if there are enough people in favour of this issue, it can be added. Let's keep this open some time and see if it gets some upvotes :)

aderuwe commented 8 years ago

I haven't really been involved much lately. But FWIW, explicit > implicit - I believe running composer (or any other similar tool) should be a conscious developer action. That way the developer stays connected to the system under development much more closely, which will also help with quality. A co-worker might have added a dependency you don't agree with; you might miss this if you let GrumPHP handle composer for you.

veewee commented 7 years ago

It looks like this one can be closed. Thanks for the suggestion, but we will not implement this feature.