2012-09-07 01:16:29 -04:00
|
|
|
require_relative 'gitolite_config'
|
2011-12-03 18:44:59 -05:00
|
|
|
|
2012-05-26 06:37:49 -04:00
|
|
|
module Gitlab
|
2011-12-03 18:44:59 -05:00
|
|
|
class Gitolite
|
|
|
|
class AccessDenied < StandardError; end
|
2012-09-07 01:16:29 -04:00
|
|
|
|
|
|
|
def config
|
2012-09-07 08:36:40 -04:00
|
|
|
Gitlab::GitoliteConfig.new
|
2012-09-07 01:16:29 -04:00
|
|
|
end
|
2011-12-03 18:44:59 -05:00
|
|
|
|
2012-08-28 17:04:06 -04:00
|
|
|
def set_key key_id, key_content, projects
|
2012-09-07 01:16:29 -04:00
|
|
|
config.apply do |config|
|
|
|
|
config.write_key(key_id, key_content)
|
|
|
|
config.update_projects(projects)
|
2012-08-28 17:04:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_key key_id, projects
|
2012-09-07 01:16:29 -04:00
|
|
|
config.apply do |config|
|
|
|
|
config.rm_key(key_id)
|
|
|
|
config.update_projects(projects)
|
2012-08-28 17:04:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_repository project
|
2012-11-27 01:31:15 -05:00
|
|
|
config.update_project!(project)
|
2012-03-05 17:26:40 -05:00
|
|
|
end
|
|
|
|
|
2012-11-27 09:35:00 -05:00
|
|
|
def move_repository(old_repo, project)
|
2012-11-21 00:54:05 -05:00
|
|
|
config.apply do |config|
|
|
|
|
config.clean_repo(old_repo)
|
2012-11-27 09:35:00 -05:00
|
|
|
config.update_project(project)
|
2012-11-21 00:54:05 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-28 17:04:06 -04:00
|
|
|
def remove_repository project
|
2012-09-07 01:16:29 -04:00
|
|
|
config.destroy_project!(project)
|
2012-03-05 17:26:40 -05:00
|
|
|
end
|
|
|
|
|
2012-08-28 17:04:06 -04:00
|
|
|
def url_to_repo path
|
2012-12-14 19:16:25 -05:00
|
|
|
Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git"
|
2012-08-28 17:04:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def enable_automerge
|
2012-09-08 07:24:38 -04:00
|
|
|
config.admin_all_repo!
|
2012-03-30 01:25:04 -04:00
|
|
|
end
|
2012-08-28 17:33:19 -04:00
|
|
|
|
2012-11-25 11:24:27 -05:00
|
|
|
def update_repositories projects
|
|
|
|
config.apply do |config|
|
|
|
|
config.update_projects(projects)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-09-07 01:16:29 -04:00
|
|
|
alias_method :create_repository, :update_repository
|
2011-12-03 18:44:59 -05:00
|
|
|
end
|
|
|
|
end
|