Commit f1c82bc56c9391abac5ba9b70e406d899cf26495
1 parent
c0f6a932
Exists in
master
and in
4 other branches
Add gitlab-shell#path option in config
Before this commit gitlab-shell but me placed directly in home dir. Ex: /home/git/gitlab-shell After this change you can place gitlab-shell in custom location. Ex: /Users/developer/gitlab/gitlab-shell Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
3 changed files
with
21 additions
and
14 deletions
Show diff stats
config/gitlab.yml.example
| ... | ... | @@ -174,6 +174,8 @@ production: &base |
| 174 | 174 | |
| 175 | 175 | ## GitLab Shell settings |
| 176 | 176 | gitlab_shell: |
| 177 | + path: /home/git/gitlab-shell/ | |
| 178 | + | |
| 177 | 179 | # REPOS_PATH MUST NOT BE A SYMLINK!!! |
| 178 | 180 | repos_path: /home/git/repositories/ |
| 179 | 181 | hooks_path: /home/git/gitlab-shell/hooks/ | ... | ... |
config/initializers/1_settings.rb
| ... | ... | @@ -114,6 +114,7 @@ Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}? |
| 114 | 114 | # GitLab Shell |
| 115 | 115 | # |
| 116 | 116 | Settings['gitlab_shell'] ||= Settingslogic.new({}) |
| 117 | +Settings.gitlab_shell['path'] ||= Settings.gitlab['user_home'] + '/gitlab-shell/' | |
| 117 | 118 | Settings.gitlab_shell['hooks_path'] ||= Settings.gitlab['user_home'] + '/gitlab-shell/hooks/' |
| 118 | 119 | Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil? |
| 119 | 120 | Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil? | ... | ... |
lib/gitlab/backend/shell.rb
| ... | ... | @@ -10,7 +10,7 @@ module Gitlab |
| 10 | 10 | # add_repository("gitlab/gitlab-ci") |
| 11 | 11 | # |
| 12 | 12 | def add_repository(name) |
| 13 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "add-project", "#{name}.git" | |
| 13 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "add-project", "#{name}.git" | |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | 16 | # Import repository |
| ... | ... | @@ -21,7 +21,7 @@ module Gitlab |
| 21 | 21 | # import_repository("gitlab/gitlab-ci", "https://github.com/randx/six.git") |
| 22 | 22 | # |
| 23 | 23 | def import_repository(name, url) |
| 24 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "import-project", "#{name}.git", url | |
| 24 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "import-project", "#{name}.git", url | |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | # Move repository |
| ... | ... | @@ -33,7 +33,7 @@ module Gitlab |
| 33 | 33 | # mv_repository("gitlab/gitlab-ci", "randx/gitlab-ci-new.git") |
| 34 | 34 | # |
| 35 | 35 | def mv_repository(path, new_path) |
| 36 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" | |
| 36 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "mv-project", "#{path}.git", "#{new_path}.git" | |
| 37 | 37 | end |
| 38 | 38 | |
| 39 | 39 | # Update HEAD for repository |
| ... | ... | @@ -45,7 +45,7 @@ module Gitlab |
| 45 | 45 | # update_repository_head("gitlab/gitlab-ci", "3-1-stable") |
| 46 | 46 | # |
| 47 | 47 | def update_repository_head(path, branch) |
| 48 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "update-head", "#{path}.git", branch | |
| 48 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "update-head", "#{path}.git", branch | |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 51 | # Fork repository to new namespace |
| ... | ... | @@ -57,7 +57,7 @@ module Gitlab |
| 57 | 57 | # fork_repository("gitlab/gitlab-ci", "randx") |
| 58 | 58 | # |
| 59 | 59 | def fork_repository(path, fork_namespace) |
| 60 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "fork-project", "#{path}.git", fork_namespace | |
| 60 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "fork-project", "#{path}.git", fork_namespace | |
| 61 | 61 | end |
| 62 | 62 | |
| 63 | 63 | # Remove repository from file system |
| ... | ... | @@ -68,7 +68,7 @@ module Gitlab |
| 68 | 68 | # remove_repository("gitlab/gitlab-ci") |
| 69 | 69 | # |
| 70 | 70 | def remove_repository(name) |
| 71 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-project", "#{name}.git" | |
| 71 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-project", "#{name}.git" | |
| 72 | 72 | end |
| 73 | 73 | |
| 74 | 74 | # Add repository branch from passed ref |
| ... | ... | @@ -81,7 +81,7 @@ module Gitlab |
| 81 | 81 | # add_branch("gitlab/gitlab-ci", "4-0-stable", "master") |
| 82 | 82 | # |
| 83 | 83 | def add_branch(path, branch_name, ref) |
| 84 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "create-branch", "#{path}.git", branch_name, ref | |
| 84 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "create-branch", "#{path}.git", branch_name, ref | |
| 85 | 85 | end |
| 86 | 86 | |
| 87 | 87 | # Remove repository branch |
| ... | ... | @@ -93,7 +93,7 @@ module Gitlab |
| 93 | 93 | # rm_branch("gitlab/gitlab-ci", "4-0-stable") |
| 94 | 94 | # |
| 95 | 95 | def rm_branch(path, branch_name) |
| 96 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-branch", "#{path}.git", branch_name | |
| 96 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-branch", "#{path}.git", branch_name | |
| 97 | 97 | end |
| 98 | 98 | |
| 99 | 99 | # Add repository tag from passed ref |
| ... | ... | @@ -106,7 +106,7 @@ module Gitlab |
| 106 | 106 | # add_tag("gitlab/gitlab-ci", "v4.0", "master") |
| 107 | 107 | # |
| 108 | 108 | def add_tag(path, tag_name, ref) |
| 109 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "create-tag", "#{path}.git", tag_name, ref | |
| 109 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "create-tag", "#{path}.git", tag_name, ref | |
| 110 | 110 | end |
| 111 | 111 | |
| 112 | 112 | # Remove repository tag |
| ... | ... | @@ -118,7 +118,7 @@ module Gitlab |
| 118 | 118 | # rm_tag("gitlab/gitlab-ci", "v4.0") |
| 119 | 119 | # |
| 120 | 120 | def rm_tag(path, tag_name) |
| 121 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects", "rm-tag", "#{path}.git", tag_name | |
| 121 | + system "#{gitlab_shell_path}/bin/gitlab-projects", "rm-tag", "#{path}.git", tag_name | |
| 122 | 122 | end |
| 123 | 123 | |
| 124 | 124 | # Add new key to gitlab-shell |
| ... | ... | @@ -127,7 +127,7 @@ module Gitlab |
| 127 | 127 | # add_key("key-42", "sha-rsa ...") |
| 128 | 128 | # |
| 129 | 129 | def add_key(key_id, key_content) |
| 130 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "add-key", key_id, key_content | |
| 130 | + system "#{gitlab_shell_path}/bin/gitlab-keys", "add-key", key_id, key_content | |
| 131 | 131 | end |
| 132 | 132 | |
| 133 | 133 | # Remove ssh key from gitlab shell |
| ... | ... | @@ -136,7 +136,7 @@ module Gitlab |
| 136 | 136 | # remove_key("key-342", "sha-rsa ...") |
| 137 | 137 | # |
| 138 | 138 | def remove_key(key_id, key_content) |
| 139 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "rm-key", key_id, key_content | |
| 139 | + system "#{gitlab_shell_path}/bin/gitlab-keys", "rm-key", key_id, key_content | |
| 140 | 140 | end |
| 141 | 141 | |
| 142 | 142 | # Remove all ssh keys from gitlab shell |
| ... | ... | @@ -145,7 +145,7 @@ module Gitlab |
| 145 | 145 | # remove_all_keys |
| 146 | 146 | # |
| 147 | 147 | def remove_all_keys |
| 148 | - system "#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-keys", "clear" | |
| 148 | + system "#{gitlab_shell_path}/bin/gitlab-keys", "clear" | |
| 149 | 149 | end |
| 150 | 150 | |
| 151 | 151 | # Add empty directory for storing repositories |
| ... | ... | @@ -198,7 +198,7 @@ module Gitlab |
| 198 | 198 | |
| 199 | 199 | # Return GitLab shell version |
| 200 | 200 | def version |
| 201 | - gitlab_shell_version_file = "#{gitlab_shell_user_home}/gitlab-shell/VERSION" | |
| 201 | + gitlab_shell_version_file = "#{gitlab_shell_path}/VERSION" | |
| 202 | 202 | |
| 203 | 203 | if File.readable?(gitlab_shell_version_file) |
| 204 | 204 | File.read(gitlab_shell_version_file) |
| ... | ... | @@ -207,6 +207,10 @@ module Gitlab |
| 207 | 207 | |
| 208 | 208 | protected |
| 209 | 209 | |
| 210 | + def gitlab_shell_path | |
| 211 | + Gitlab.config.gitlab_shell.path | |
| 212 | + end | |
| 213 | + | |
| 210 | 214 | def gitlab_shell_user_home |
| 211 | 215 | File.expand_path("~#{Gitlab.config.gitlab_shell.ssh_user}") |
| 212 | 216 | end | ... | ... |