forked from redmine-git-hosting/redmine_git_hosting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.rb
97 lines (83 loc) · 4.03 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# coding: utf-8
require 'redmine'
require 'redmine_git_hosting'
Redmine::Plugin.register :redmine_git_hosting do
name 'Redmine Git Hosting Plugin'
author 'Eric Bishop, Pedro Algarvio, Christian Käser, Zsolt Parragi, Yunsang Choi, Joshua Hogendorn, Jan Schulz-Hofen, John Kubiatowicz, Nicolas Rodriguez and others'
description 'Enables Redmine / ChiliProject to control hosting of Git repositories through Gitolite'
version '0.6.2'
url 'https://github.com/jbox-web/redmine_git_hosting'
author_url 'https://github.com/jbox-web'
settings({
:partial => 'settings/redmine_git_hosting',
:default => {
'gitLockWaitTime' => '10',
'gitTempDataDir' => (ENV['HOME'] + "/tmp/redmine_git_hosting/").to_s,
'gitScriptDir' => '',
'gitUser' => 'git',
'gitoliteIdentityFile' => (ENV['HOME'] + "/.ssh/redmine_gitolite_admin_id_rsa").to_s,
'gitoliteIdentityPublicKeyFile' => (ENV['HOME'] + "/.ssh/redmine_gitolite_admin_id_rsa.pub").to_s,
'sshServerLocalPort' => '22',
'gitConfigFile' => 'gitolite.conf',
'gitConfigHasAdminKey' => true,
'gitRepositoryBasePath' => 'repositories/',
'gitRedmineSubdir' => '',
'gitRepositoryHierarchy' => false,
'gitRepositoryIdentUnique' => true,
'allProjectsUseGit' => false,
'gitDaemonDefault' => '1',
'gitHttpDefault' => '1',
'gitNotifyCIADefault' => '0',
'deleteGitRepositories' => false,
'gitRecycleBasePath' => 'recycle_bin/',
'gitRecycleExpireTime' => '24.0',
'gitServer' => 'localhost',
'httpServer' => 'localhost',
'httpServerSubdir' => '',
'gitRepositoriesShowUrl' => true,
'gitCacheMaxElements' => '100',
'gitCacheMaxTime' => '-1',
'gitCacheMaxSize' => '16',
'gitHooksAreAsynchronous' => true,
'gitHooksDebug' => false,
'gitForceHooksUpdate' => true,
}
})
project_module :repository do
permission :create_repository_mirrors, :repository_mirrors => :create
permission :view_repository_mirrors, :repository_mirrors => :index
permission :edit_repository_mirrors, :repository_mirrors => :edit
permission :create_repository_post_receive_urls, :repository_post_receive_urls => :create
permission :view_repository_post_receive_urls, :repository_post_receive_urls => :index
permission :edit_repository_post_receive_urls, :repository_post_receive_urls => :edit
permission :create_deployment_keys, :deployment_credentials => :create_with_key
permission :view_deployment_keys, :deployment_credentials => :index
permission :edit_deployment_keys, :deployment_credentials => :edit
end
end
# initialize observer
# Don't initialize this while doing migration of primary system (i.e. Redmine/Chiliproject)
migrating_primary = (File.basename($0) == "rake" && ARGV.include?("db:migrate"))
if Rails::VERSION::MAJOR >= 3
Rails.configuration.after_initialize do
if !migrating_primary
ActiveRecord::Base.observers << GitHostingObserver
ActiveRecord::Base.observers << GitHostingSettingsObserver
GitHostingObserver.instance.reload_this_observer
GitHostingSettingsObserver.instance.reload_this_observer
end
end
else
config.after_initialize do
if !migrating_primary
ActiveRecord::Base.observers = ActiveRecord::Base.observers << GitHostingObserver
ActiveRecord::Base.observers = ActiveRecord::Base.observers << GitHostingSettingsObserver
ActionController::Dispatcher.to_prepare(:git_hosting_observer_reload) do
GitHostingObserver.instance.reload_this_observer
end
ActionController::Dispatcher.to_prepare(:git_hosting_settings_observer_reload) do
GitHostingSettingsObserver.instance.reload_this_observer
end
end
end
end