Code Monkey home page Code Monkey logo

Comments (16)

k00p avatar k00p commented on May 10, 2024 8

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.

from gollum.

k00p avatar k00p commented on May 10, 2024 2

@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.

from gollum.

bartkamphorst avatar bartkamphorst commented on May 10, 2024 2

@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

from gollum.

pReya avatar pReya commented on May 10, 2024 2

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

from gollum.

technoweenie avatar technoweenie commented on May 10, 2024

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.

from gollum.

schacon avatar schacon commented on May 10, 2024

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.

from gollum.

dentarg avatar dentarg commented on May 10, 2024

+1

from gollum.

atmos avatar atmos commented on May 10, 2024

Closing until grit gets support for this.

from gollum.

lattera avatar lattera commented on May 10, 2024

+1

from gollum.

pejvan avatar pejvan commented on May 10, 2024

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?

from gollum.

dometto avatar dometto commented on May 10, 2024

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!

from gollum.

pejvan avatar pejvan commented on May 10, 2024

@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

from gollum.

dkozel avatar dkozel commented on May 10, 2024

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

from gollum.

pejvan avatar pejvan commented on May 10, 2024

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 [email protected] 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).

from gollum.

pReya avatar pReya commented on May 10, 2024

@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?

from gollum.

bartkamphorst avatar bartkamphorst commented on May 10, 2024

Good to hear!

from gollum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.