shell.rb 1.17 KB
Newer Older
1
module Gitlab
2
  class Shell
3
    class AccessDenied < StandardError; end
4

5
    # Init new repository
6
    #
7
    # name - project path with namespace
8 9
    #
    # Ex.
10
    #   add_repository("gitlab/gitlab-ci")
11
    #
12 13
    def add_repository(name)
      system("/home/git/gitlab-shell/bin/gitlab-projects add-project #{name}.git")
14 15
    end

16
    # Remove repository from file system
17 18 19 20 21 22 23
    #
    # name - project path with namespace
    #
    # Ex.
    #   remove_repository("gitlab/gitlab-ci")
    #
    def remove_repository(name)
24
      system("/home/git/gitlab-shell/bin/gitlab-projects rm-project #{name}.git")
25 26
    end

27
    # Add new key to gitlab-shell
28
    #
29
    # Ex.
30
    #   add_key("key-42", "sha-rsa ...")
31
    #
32 33
    def add_key(key_id, key_content)
      system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"")
34 35 36
    end

    # Remove ssh key from gitlab shell
37 38
    #
    # Ex.
39
    #   remove_key("key-342", "sha-rsa ...")
40
    #
41 42
    def remove_key(key_id, key_content)
      system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
43 44
    end

45

46
    def url_to_repo path
47
      Gitlab.config.gitolite.ssh_path_prefix + "#{path}.git"
48
    end
49 50
  end
end