Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
executable file 107 lines (87 sloc) 4.19 KB
# 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
Something went wrong with that request. Please try again.