forked from ericpaulbishop/redmine_git_hosting
-
Notifications
You must be signed in to change notification settings - Fork 1
/
init.rb
50 lines (43 loc) · 2.42 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
require 'redmine'
require_dependency 'principal'
require_dependency 'user'
require_dependency 'member'
require_dependency 'gitosis'
require 'gitosis/patches/application_controller_patch'
require 'gitosis/patches/repositories_controller_patch'
require 'gitosis/patches/repositories_helper_patch'
require 'gitosis/patches/git_adapter_patch'
Dispatcher.to_prepare do
GitosisObserver.instance
require 'repositories_controller'
ApplicationController.send(:include, Gitosis::Patches::ApplicationControllerPatch) unless ApplicationController.included_modules.include?(Gitosis::Patches::ApplicationControllerPatch)
RepositoriesController.send(:include, Gitosis::Patches::RepositoriesControllerPatch) unless RepositoriesController.include?(Gitosis::Patches::RepositoriesControllerPatch)
RepositoriesController.send(:include, Gitosis::Patches::ApplicationControllerPatch) unless RepositoriesController.included_modules.include?(Gitosis::Patches::ApplicationControllerPatch)
RepositoriesHelper.send(:include, Gitosis::Patches::RepositoriesHelperPatch) unless RepositoriesHelper.include?(Gitosis::Patches::RepositoriesHelperPatch)
Redmine::Scm::Adapters::GitAdapter.send(:include, Gitosis::Patches::GitAdapterPatch) unless Redmine::Scm::Adapters::GitAdapter.include?(Gitosis::Patches::GitAdapterPatch)
# initialize association from user -> public keys
User.send(:has_many, :gitosis_public_keys, :dependent => :destroy)
# initialize observer
ActiveRecord::Base.observers = ActiveRecord::Base.observers << GitosisObserver
end
Redmine::Plugin.register :redmine_gitosis do
name 'Redmine Gitosis plugin'
author 'Jan Schulz-Hofen'
description 'Enables Redmine to update a gitosis server.'
version '0.0.5alpha'
settings :default => {
'gitosisUrl' => 'git@localhost:gitosis-admin.git',
'gitosisIdentityFile' => '/srv/projects/redmine/miner/.ssh/id_rsa',
'developerBaseUrls' => '[email protected]:,https://[user]@www.salamander-linux.com/git/',
'readOnlyBaseUrls' => 'http://www.salamander-linux.com/git/',
'basePath' => '/srv/projects/git/repositories/',
},
:partial => 'redmine_gitosis'
end
# initialize hook
class GitosisPublicKeyHook < Redmine::Hook::ViewListener
render_on :view_my_account_contextual, :inline => "| <%= link_to(l(:label_public_keys), public_keys_path) %>"
end
class GitosisProjectShowHook < Redmine::Hook::ViewListener
render_on :view_projects_show_left, :partial => 'redmine_gitosis'
end