gitolite.rb 1.17 KB
Newer Older
1
require_relative 'gitolite_config'
2

3
module Gitlab
4 5
  class Gitolite
    class AccessDenied < StandardError; end
6 7

    def config
8
      Gitlab::GitoliteConfig.new
9
    end
10

11
    def set_key key_id, key_content, projects
12 13 14
      config.apply do |config|
        config.write_key(key_id, key_content)
        config.update_projects(projects)
15 16 17 18
      end
    end

    def remove_key key_id, projects
19 20 21
      config.apply do |config|
        config.rm_key(key_id)
        config.update_projects(projects)
22 23 24 25
      end
    end

    def update_repository project
26
      config.update_project!(project)
27 28
    end

29 30 31 32 33 34 35
    def move_repository(old_repo, new_repo, project)
      config.apply do |config|
        config.clean_repo(old_repo)
        config.update_project(new_repo, project)
      end
    end

36
    def remove_repository project
37
      config.destroy_project!(project)
38 39
    end

40 41 42 43 44
    def url_to_repo path
      Gitlab.config.ssh_path + "#{path}.git"
    end

    def enable_automerge
45
      config.admin_all_repo!
46
    end
47

48 49 50 51 52 53
    def update_repositories projects
      config.apply do |config|
        config.update_projects(projects)
      end
    end

54
    alias_method :create_repository, :update_repository
55 56
  end
end