Skip to content

Commit 60716ac

Browse files
author
Nicolas Rodriguez
committed
Improve custom Gitolite hook loading
1 parent ff2c20c commit 60716ac

File tree

3 files changed

+46
-36
lines changed

3 files changed

+46
-36
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ settings.yml
55
/rdoc
66
/coverage
77
/junit
8+
custom_hooks.rb

custom_hooks.rb.example

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# You can declare here you own hooks to install globally in Gitolite.
2+
# You must set the source directory of the files with the *source_dir* method and
3+
# declare your hooks with *gitolite_hook* method.
4+
#
5+
# *RedmineGitHosting::GitoliteHooks.register_hooks* can be called multiple times
6+
# with a different *source_dir*.
7+
#
8+
# *name* : the hook name (just a name to identify the hook)
9+
# *source* : the source path concatenated with *source_dir*
10+
# *destination* : the destination path on Gitolite side.
11+
#
12+
# The *destination* must be relative.
13+
# The final destination will depend on your Gitolite version :
14+
#
15+
# Gitolite v2 : <gitolite_home_dir>/.gitolite/hooks/common
16+
# Gitolite v3 : <gitolite_home_dir>/local/hooks/common/
17+
#
18+
# RedmineGitHosting::GitoliteHooks.register_hooks do
19+
# source_dir '/tmp/global-hooks'
20+
#
21+
# gitolite_hook do
22+
# name 'global/check-branch'
23+
# source 'pre-receive/check_branch.rb'
24+
# destination 'pre-receive.d/check_branch.rb'
25+
# executable true
26+
# end
27+
# end
28+
#
29+
# RedmineGitHosting::GitoliteHooks.register_hooks do
30+
# source_dir '/tmp/custom-hooks'
31+
#
32+
# gitolite_hook do
33+
# name 'custom/notify-users'
34+
# source 'post-receive/notify_users.rb'
35+
# destination 'post-receive.d/notify_users.rb'
36+
# executable true
37+
# end
38+
# end

lib/load_gitolite_hooks.rb

+7-36
Original file line numberDiff line numberDiff line change
@@ -64,39 +64,10 @@
6464
end
6565
end
6666

67-
68-
# You can declare here you own hooks to install globally in Gitolite.
69-
# You must set the source directory of the files with the *source_dir* method and
70-
# declare your hooks with *gitolite_hook* method. (see above)
71-
#
72-
# *RedmineGitHosting::GitoliteHooks.register_hooks* can be called multiple times
73-
# with a different *source_dir*.
74-
#
75-
# *name* : the hook name (to identify the hook)
76-
# *source* : the source path concatenated with *source_dir*
77-
# *destination* : the destination path on Gitolite side.
78-
#
79-
# The *destination* must be relative.
80-
# The final destination depends on your Gitolite version :
81-
#
82-
# Gitolite v3 : <gitolite_home_dir>/local/hooks/common/
83-
# Gitolite v2 : <gitolite_home_dir>/.gitolite/hooks/common
84-
#
85-
# RedmineGitHosting::GitoliteHooks.register_hooks do
86-
# # Set source directory : /tmp/foo
87-
# source_dir File.join('/', 'tmp', 'foo')
88-
#
89-
# gitolite_hook do
90-
# # Hook name
91-
# name 'bar.rb'
92-
#
93-
# # Will be /tmp/foo/pre-receive/lib/bar.rb
94-
# source 'pre-receive/lib/bar.rb'
95-
#
96-
# # Will be <gitolite_home_dir>/local/hooks/common/lib_toto/test.rb (Gitolite v3)
97-
# # Will be <gitolite_home_dir>/.gitolite/hooks/common/lib_toto/test.rb (Gitolite v2)
98-
# destination 'lib_toto/test.rb'
99-
#
100-
# executable false
101-
# end
102-
# end
67+
# Gitolite hooks can be found in Redmine root dir or in plugin root dir
68+
[
69+
Rails.root.join('redmine_git_hosting_hooks.rb').to_s,
70+
Rails.root.join('plugins', 'redmine_git_hosting', 'custom_hooks.rb').to_s
71+
].each do |file|
72+
require_dependency file if File.exist?(file)
73+
end

0 commit comments

Comments
 (0)