diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 18:08:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-29 18:08:59 +0300 |
commit | 23288f62da73fb0e30d8e7ce306665e8fda1b932 (patch) | |
tree | 2baf1339e4d7c7c35d6b8a52cfb90597a5d4cdf1 /app/controllers/projects/repositories_controller.rb | |
parent | 7cc6872401eb487ed20dbb9d455f8bb9c97d9e39 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/projects/repositories_controller.rb')
-rw-r--r-- | app/controllers/projects/repositories_controller.rb | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 2ed29b937ad..19a8df3e9a5 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -81,7 +81,7 @@ class Projects::RepositoriesController < Projects::ApplicationController def assign_archive_vars if params[:id] - @ref, @filename = extract_ref(params[:id]) + @ref, @filename = extract_ref_and_filename(params[:id]) else @ref = params[:ref] @filename = nil @@ -89,6 +89,26 @@ class Projects::RepositoriesController < Projects::ApplicationController rescue InvalidPathError render_404 end + + # path can be of the form: + # master + # master/first.zip + # master/first/second.tar.gz + # master/first/second/third.zip + # + # In the archive case, we know that the last value is always the filename, so we + # do a greedy match to extract the ref. This avoid having to pull all ref names + # from Redis. + def extract_ref_and_filename(id) + path = id.strip + data = path.match(/(.*)\/(.*)/) + + if data + [data[1], data[2]] + else + [path, nil] + end + end end Projects::RepositoriesController.prepend_if_ee('EE::Projects::RepositoriesController') |