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

git hooks are not firing when using gollum web interface #69

Closed
ghost opened this issue Nov 2, 2010 · 16 comments
Closed

git hooks are not firing when using gollum web interface #69

ghost opened this issue Nov 2, 2010 · 16 comments

Comments

@ghost
Copy link

ghost commented Nov 2, 2010

In my wiki git repository, I created a post-commit hook which should push the commit changes to the remote server

#!/usr/bin/env bash
git push myserver master
exit

Manual commits fire the hook, however commits when editing gollum interface do not seem to fire post-commit hook. Am I missing something and/or doing something outrageously odd way?

I'm new to both gollum and git, so please be patient to my ignorance.

@technoweenie
Copy link
Contributor

This is an omission of Grit::Index. It's basically an implementation of the Git commit process in ruby. In the meantime, someone can probably add hook support into Grit, or Rugged/libgit2 when that's ready. Gollum uses Grit now as its primary ruby library, but I hope to move it to Rugged someday.

@schacon
Copy link
Contributor

schacon commented Dec 8, 2010

the place we write the commit in Grit does not handle local hooks yet. we may get to it, but if you want to help out it's right around line 140 in the Grit::Index file in the Grit project. code would have to be added around the 'update_ref' line to check for executable hooks and attempt to fire them.

@dentarg
Copy link
Contributor

dentarg commented Mar 25, 2012

+1

@atmos
Copy link
Contributor

atmos commented May 4, 2012

Closing until grit gets support for this.

@lattera
Copy link

lattera commented Aug 3, 2012

+1

@pejvan
Copy link

pejvan commented Jan 2, 2015

It's been 4 years since this ticket has been closed, and I'm sure rugged/libgit2 has evolved quite a bit during that time. I'm not a ruby guy, but any chance to reopen this item?

@dometto
Copy link
Member

dometto commented Jan 2, 2015

Based on the discussion here, it looks like libgit2 doesn't support hooks yet (and will do so in the future only to the extent that the library will provide callbacks with info about local hooks). However, in the mean time, gollum has implemented it's own post-commit callbacks: see https://github.com/gollum/gollum-lib#api-documentation. Such gollum-specific hooks can be set in the optional config.rb file (but of course, the hooks will not be run when committing from outside the gollum webinterface). Hope that's useful to you!

@pejvan
Copy link

pejvan commented Jan 2, 2015

@dometto — thanks for the detailed reply along with a solution! It looks like there's a very good reason for me to learn some basic Ruby then.
The fact that hooks are not ran outside of the web interface is fine

@dkozel
Copy link

dkozel commented May 28, 2015

@pejvan Did you get your hook working? I am hoping to implement a post-commit hook to push the repo to a remote master.

@pejvan
Copy link

pejvan commented May 28, 2015

Hi Derek.
As I'm not a Ruby guy by any means, I spent some time looking for some
documentation which I never found.
I have an idea about I would implement it, but I'm really really
surprised nobody has ever implemented such a hook and added it to the
Gollum code tree...
I still have this as a todo item, but it's not a high priority item in the
long list, so currently, we do manual pushes from time to time.
If you have implemented a hook already, i'm a taker :-)
Many thanks,
Pejvan

On 28 May 2015 at 15:55, Derek Kozel notifications@github.com wrote:

@pejvan https://github.com/pejvan Did you get your hook working? I am
hoping to implement a post-commit hook to push the repo to a remote master.


Reply to this email directly or view it on GitHub
#69 (comment).

@k00p
Copy link

k00p commented Feb 21, 2017

To get gollum to respect git hooks, in a config.rb file I added:

Gollum::Hook.register(:post_commit, :hook_id) do |committer, sha1|
        system('/path/to/wiki/.git/hooks/post-commit')
end

This file then has to be specified using the --config option.

@pReya
Copy link

pReya commented Jun 12, 2020

@k00p Is this code specific to the used git adapter? Will this run both on grit and rugged? Also is there any way to debug this? Doesn't seem to get called in my case. Not a ruby developer. Can I just print to stdout to verify this snippet is being called?

@k00p
Copy link

k00p commented Jun 13, 2020

@pReya It has been a really long time since I was working with this, but I can tell you that I was working on synchronizing a GitLab based project wiki with a local Gollum instance running in a RedHat 6.5 environment. I no longer have access to that project, so I can’t really provide much more detail, I’m afraid. I do recall writing some instrumentation to confirm that it was running, so it should be possible to write to a log or a terminal. I wish I could help more. Best of luck to you.

@bartkamphorst
Copy link
Member

@pReya I can confirm that @k00p 's snippet still works on gollum 5.0.1 with the rugged adapter.

Can I just print to stdout to verify this snippet is being called?

Yes, puts statements show up in your gollum server log.

Gollum::Hook.register(:post_commit, :hook_id) do |committer, sha1|
  puts "post commit hook called"
end

@pReya
Copy link

pReya commented Jun 14, 2020

@bartkamphorst Thanks! I got it working! Not sure what the problem was. Probably wrong path for the config file.

@bartkamphorst
Copy link
Member

Good to hear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests