forked from kubitron/redmine_git_hosting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.rb
executable file
·106 lines (96 loc) · 4.32 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
98
99
100
101
102
103
104
105
106
# coding: utf-8
require 'redmine'
require File.join(File.dirname(__FILE__), 'app', 'models', 'git_repository_extra')
require File.join(File.dirname(__FILE__), 'app', 'models', 'git_cia_notification')
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 and others'
description 'Enables Redmine / ChiliProject to control hosting of git repositories'
version '0.5.1x'
url 'https://github.com/ericpaulbishop/redmine_git_hosting'
settings :default => {
'httpServer' => 'localhost',
'httpServerSubdir' => '',
'gitServer' => 'localhost',
'gitUser' => 'git',
'gitConfigPath' => 'gitolite.conf', # Redmine gitolite config file
'gitConfigHasAdminKey' => 'true', # Conf file should have admin key
'gitRepositoryBasePath' => 'repositories/',
'gitRedmineSubdir' => '',
'gitRepositoryHierarchy' => 'true',
'gitRecycleBasePath' => 'recycle_bin/',
'gitRecycleExpireTime' => '24.0',
'gitLockWaitTime' => '10',
'gitoliteIdentityFile' => RAILS_ROOT + '/.ssh/gitolite_admin_id_rsa',
'gitoliteIdentityPublicKeyFile' => RAILS_ROOT + '/.ssh/gitolite_admin_id_rsa.pub',
'allProjectsUseGit' => 'false',
'gitDaemonDefault' => '1', # Default is Daemon enabled
'gitHttpDefault' => '1', # Default is HTTP_ONLY
'gitNotifyCIADefault' => '0', # Default is CIA Notification disabled
'deleteGitRepositories' => 'false',
'gitRepositoriesShowUrl' => 'true',
'gitCacheMaxTime' => '-1',
'gitCacheMaxElements' => '100',
'gitCacheMaxSize' => '16',
'gitHooksDebug' => 'false',
'gitHooksAreAsynchronous' => 'true',
'gitTempDataDir' => '/tmp/redmine_git_hosting/',
'gitScriptDir' => '',
'gitForceHooksUpdate' => 'true',
'gitRepositoryIdentUnique' => 'true'
},
:partial => 'redmine_git_hosting'
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
# Set up autoload of patches
require 'dispatcher' unless Rails::VERSION::MAJOR >= 3
def git_hosting_patch(&block)
if Rails::VERSION::MAJOR >= 3
ActionDispatch::Calbacks.to_prepare(&block)
else
Dispatcher.to_prepare(:redmine_git_patches,&block)
end
end
git_hosting_patch do
patches=Dir[File.dirname(__FILE__)+"/lib/git_hosting/patches/*.rb"].map{|x| File.basename(x,".rb")}.sort
# Special positioning necessary
# Put git_adapter_patch last (make sure that git_cmd stays patched!)
patches = (patches-["git_adapter_patch"]) << "git_adapter_patch"
patches.each do |patch|
require_dependency 'git_hosting/patches/'+File.basename(patch,".rb")
end
end
# initialize hooks
class GitProjectShowHook < Redmine::Hook::ViewListener
render_on :view_projects_show_left, :partial => 'git_urls'
end
class GitRepoUrlHook < Redmine::Hook::ViewListener
render_on :view_repositories_show_contextual, :partial => 'git_urls'
end
# Put Git SCM first in list of SCMs
Redmine::Scm::Base.all.unshift("Git").uniq!
# 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"))
config.after_initialize do
if config.action_controller.perform_caching && !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