-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Use Git Hooks with Composer #1083
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
Conversation
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.
Could you add support for just composer? Because people tend to rename it when installing it at the system level.
|
Running |
|
ping @RobLoach? :) |
|
@RobLoach @stof This might do as a fairly basic diff of the old and new # -e is supposed to inhibit all output but it doesn't...
( git cat-file -e "$1:composer.lock" >/dev/null 2>&1 ) && ( git cat-file -e "$2:composer.lock" >/dev/null 2>&1 ) && ( git diff --quiet "$1:composer.lock" "$2:composer.lock" ) && exit(Might not correctly handle all the different combinations of |
|
Might also be useful if this doc also contained a sample |
|
I did that in my dotfiles: https://gist.github.com/lyrixx/5867424 |
|
@lyrixx Cool! I think the conditional can be simplified to: if git diff --quiet $PREV_COMMIT..$POST_COMMIT composer.lock ; then
...
fiNone of these solutions help with the problem of a |
|
@ithinkihaveacat Are you sure ? because it works git rebase. |
|
@ithinkihaveacat simply does a similar hook for |
|
There are just so many different places and workflows how Composer could live. |
|
@stof Unfortunately, |
|
@ithinkihaveacat A merge commit allows to know both parent commits, and IIRC, it even allows knowing which one was the commit of the current branch and which one was the commit of the merged branch |
|
for a post merge, it is probably a matter of doing a |
|
@stof Thanks, I'll experiment. There's also the fast-forward "merge" situation to consider. |
|
Did the ultimate composer git hook script get published in the end? |
|
Not sure. Ping @RobLoach? Is anyone actually using this successfully? I'd like to get real world feedback before adding it to the docs. |
|
Didn't end up using it. Having the installation as part of the git hook seems undesired. Might be good to just assume it's at |
|
@Seldaek I just display a message if composer.json is different. And yes it's work very well, and it's very important for me. |
|
@lyrixx would you care to take over this PR and share your solution? It sounds like a superior solution to warn but not automatically update. Don't you warn on composer.lock changes though? |
|
That's a much more graceful solution, agreed. Thanks, you two. |
|
@Seldaek Sorry. I mean when the You can have a look to this file BTW, you can run Anyway, as this issue is closed, what could I do for you? |
|
I suggest you open a new PR adding your hook to the documentation (well, minus the chef check of course) |
Provide "post-checkout" git hook documentation that updates Composer's dependencies whenever a checkout is run.
http://book.git-scm.com/5_git_hooks.html