forked from kubitron/redmine_git_hosting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.rb
executable file
·140 lines (115 loc) · 5.57 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# coding: utf-8
require 'redmine'
require_dependency 'principal'
require_dependency 'user'
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.4.5x'
url '/~https://github.com/ericpaulbishop/redmine_git_hosting'
settings :default => {
'httpServer' => 'localhost',
'httpServerSubdir' => '',
'gitServer' => 'localhost',
'gitUser' => 'git',
'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' => ''
},
: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
end
end
require "dispatcher"
Dispatcher.to_prepare :redmine_git_patches do
require_dependency 'git_hosting'
# initialize association from project -> repository mirrors
Project.send(:has_many, :repository_mirrors, :dependent => :destroy)
# initialize association from project -> repository post receive urls
Project.send(:has_many, :repository_post_receive_urls, :dependent => :destroy)
require_dependency 'projects_controller'
require 'git_hosting/patches/projects_controller_patch'
ProjectsController.send(:include, GitHosting::Patches::ProjectsControllerPatch)
require_dependency 'repositories_controller'
require 'git_hosting/patches/repositories_controller_patch'
RepositoriesController.send(:include, GitHosting::Patches::RepositoriesControllerPatch)
require_dependency 'repository'
require 'git_hosting/patches/repository_patch'
Repository.send(:include, GitHosting::Patches::RepositoryPatch)
require 'stringio'
require_dependency 'redmine/scm/adapters/git_adapter'
require 'git_hosting/patches/git_adapter_patch'
Redmine::Scm::Adapters::GitAdapter.send(:include, GitHosting::Patches::GitAdapterPatch)
require_dependency 'groups_controller'
require 'git_hosting/patches/groups_controller_patch'
GroupsController.send(:include, GitHosting::Patches::GroupsControllerPatch)
require_dependency 'repository'
require_dependency 'repository/git'
require 'git_hosting/patches/git_repository_patch'
Repository::Git.send(:include, GitHosting::Patches::GitRepositoryPatch)
require_dependency 'sys_controller'
require 'git_hosting/patches/sys_controller_patch'
SysController.send(:include, GitHosting::Patches::SysControllerPatch)
require_dependency 'members_controller'
require 'git_hosting/patches/members_controller_patch'
MembersController.send(:include, GitHosting::Patches::MembersControllerPatch)
# initialize association from user -> public keys
User.send(:has_many, :gitolite_public_keys, :dependent => :destroy)
require_dependency 'users_controller'
require 'git_hosting/patches/users_controller_patch'
UsersController.send(:include, GitHosting::Patches::UsersControllerPatch)
require_dependency 'roles_controller'
require 'git_hosting/patches/roles_controller_patch'
RolesController.send(:include, GitHosting::Patches::RolesControllerPatch)
require_dependency 'my_controller'
require 'git_hosting/patches/my_controller_patch'
MyController.send(:include, GitHosting::Patches::MyControllerPatch)
require_dependency 'git_hosting/patches/repository_cia_filters'
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
# initialize observer
config.after_initialize do
if config.action_controller.perform_caching
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