Comments (16)
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.
@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.
@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.
@bartkamphorst Thanks! I got it working! Not sure what the problem was. Probably wrong path for the config file.
from gollum.
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.
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.
+1
from gollum.
Closing until grit gets support for this.
from gollum.
+1
from gollum.
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.
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.
@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.
@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.
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.
@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.
Good to hear!
from gollum.
Related Issues (20)
- Cancellation should prompt before data loss HOT 2
- Checkout System?
- Feature request: support for wikis in subdirectories HOT 1
- How to fast forward when possible? HOT 1
- Running Docker image results in error due to git security configuration HOT 2
- Running tests fails if git's `init.defaultbranch` is not set to `master` HOT 5
- Setting the gollum author environment variables doesn't make the Git commit use them. HOT 1
- Symlink page edit editing the symlink instead of target + leaves tree with unstaged changes HOT 1
- Investigate server error reporting on save HOT 2
- Failed to install on Ubuntu 22.04 HOT 3
- Failed to run `java gollum.war` resulting in thread error HOT 3
- Ask a question
- Problems caused by language HOT 4
- Navigation macro does not recognize explicit false for sub_path HOT 2
- YAML frontmatter cannot have a folded scalar HOT 1
- git creates 'main' as default branch HOT 1
- Redirects to incorrect page when being served behind nginx proxy HOT 4
- Move from RACK_ENV to APP_ENV HOT 4
- Move from master to main as default branch HOT 4
- No API in `A simple, Git-powered wiki with a sweet API and local frontend. ` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gollum.