-
-
Notifications
You must be signed in to change notification settings - Fork 364
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
Add support for Git Hooks #1186
Comments
If you want to spawn new process you need to think about the browsers. I think that, if implemented,it should be compatible with canonical git but in browsers you don't have processes. |
Definately @jcubic. My primary usage for I'm thinking that, if we move forward with integrating this logic into the package itself (as opposed to making a new one via the plugin system), that we allow passing a |
Maybe the solution is to use some kind of events in the library, the old version if the library had an emitter option. But it got removed I think this will require thinking how those events will be added. |
I would like to implement this issue. My idea is use similar strategy like in hooks: {
preCommit?: ({fs, http, dir, gitdir}) => Promise<{fs, http, dir, gitdir}>,
prepareCommitMsg?: ({fs, http, dir, gitdir, message, source, oid}) => Promise<{fs, http, dir, gitdir, message, source, oid}>,
prePush?: ({fs, http, dir, gitdir, remote, url, refs}) => Promise<{fs, http, dir, gitdir, remote, url, refs}>,
...
} For each hook exists one function (just as exists only one script in Supporting hooks from Still there is some details to think about:
|
@CoalZombik what is your use case with Git hooks? I now thinking about this and I'm wondering what is the point of having hooks. If you have code that runs git.commit, why do you need pre-commit if you can create an Adapter that will do your code and then invoke git.commit? Why making the library more complex? It's your code that executes the git function. With canonical git it's different because it's single command and if you want to invoke some code automatically you need to write git hook. I don't think that you can have the same functionality with aliases git hooks are more convenient for this purpose. But if you have API and programming language you have full control over git functions, so you don't need hooks. Unless there are hooks into the internals of git. Also if you want to use |
I am thinking about some support of git lfs that need (Now I release I had talk about this in lfs issue first and don't want to implement only part of whole, sorry about that.) |
I'm ok for hooks if they get internals of git like refs. But we need to come up with an API that will match the current architecture of passing stuff to each function. |
I looked more deeply to existing git hooks and I realized only two hooks is worth it to implement:
About API, I am thinking about callback that is passed to related function and called in valid time, same as for example |
Sounds like a plan |
Sorry for very long response, but I finally created a pull request with implementation of these two hooks. |
I'd love to see support for the git hooks. Some of these hooks are:
pre-commit
prepare-commit-msg
commit-msg
post-commit
post-merge
pre-push
And others. They can be found via this resource and this resource in a more "plain-english" way.
I'm willing to implement this functionality, however, I'm wondering what the API should look like. Do we want to look for the related files and run them with
spawn
? Do we want to makepre-X
andpost-X
actions and utilize a plugin-like system and provide this logic as an additional package? What do we think?The text was updated successfully, but these errors were encountered: