diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-10-28 15:55:55 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-10-28 15:55:55 +0300 |
commit | 440604ad1ba67dcbdd23633765b9140fae4bd4b9 (patch) | |
tree | 1fecd6c598d74aec84480b6cd93b57d1bde80159 /app/models/repository.rb | |
parent | 3095ac0ca45b044f2055cbd44654c83891245928 (diff) | |
download | gitlab-ce-dz-internal-api-fullpath.tar.gz |
Refactor storage path extraction from full repo pathdz-internal-api-fullpath
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 4ae9c20726f..e2b0093859d 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -11,6 +11,20 @@ class Repository attr_accessor :path_with_namespace, :project + def self.storages + Gitlab.config.repositories.storages + end + + def self.remove_storage_from_path(repo_path) + storages.find do |_, storage_path| + if repo_path.start_with?(storage_path) + return repo_path.sub(storage_path, '') + end + end + + repo_path + end + def initialize(path_with_namespace, project) @path_with_namespace = path_with_namespace @project = project |