forked from ericpaulbishop/redmine_git_hosting
-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.rb
executable file
·106 lines (87 loc) · 4.19 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
# 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 and others'
description 'Enables Redmine / ChiliProject to control hosting of git repositories'
version '0.4.2'
url 'https://github.com/ericpaulbishop/redmine_git_hosting'
settings :default => {
'httpServer' => 'localhost',
'gitServer' => 'localhost',
'gitUser' => 'git',
'gitRepositoryBasePath' => 'repositories/',
'gitoliteIdentityFile' => RAILS_ROOT + '/.ssh/gitolite_admin_id_rsa',
'gitoliteIdentityPublicKeyFile' => RAILS_ROOT + '/.ssh/gitolite_admin_id_rsa.pub',
'allProjectsUseGit' => 'false',
'deleteGitRepositories' => 'false',
'gitRepositoriesShowUrl' => 'true',
'gitCacheMaxTime' => '-1',
'gitCacheMaxElements' => '100',
'gitCacheMaxSize' => '16',
'gitHooksDebug' => 'false',
'gitHooksAreAsynchronous' => '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
end
end
require "dispatcher"
Dispatcher.to_prepare :redmine_git_patches do
require_dependency 'git_hosting'
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 '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 association from user -> public keys
User.send(:has_many, :gitolite_public_keys, :dependent => :destroy)
# initialize association from git repository -> extra
Repository.send(:has_one, :extra, :foreign_key =>'repository_id', :class_name => 'GitRepositoryExtra', :dependent => :destroy)
Repository.send(:has_many, :cia_notifications, :foreign_key =>'repository_id', :class_name => 'GitCiaNotification', :dependent => :destroy, :extend => GitHosting::Patches::RepositoryCiaFilters::FilterMethods)
# initialize association from project -> repository mirrors
Project.send(:has_many, :repository_mirrors, :dependent => :destroy)
# 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