Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2016-11-15 15:15:43 +0300
committerDouwe Maan <douwe@gitlab.com>2016-11-15 15:15:43 +0300
commitb3616e3074202d63a4ed03bbe94b14a4488c7800 (patch)
tree0492ad9e4b09c6a5eee90a821588a7563408b9a1 /lib/api
parent374b8e95c38833d6aeee491b077bd43c023c0686 (diff)
parent5c966f70fb218d6f4de0f888733604293f36c33e (diff)
Merge branch 'master-recursiveTree' into 'master'
Issue #4270: Recursive option for files through API ## What does this MR do? - Adds recursive param to tree API request. With this param we can get all repository paths in a single request. - Related [old github pull request](https://github.com/gitlabhq/gitlabhq/pull/9311) ## Are there points in the code the reviewer needs to double check? ## Why was this MR needed? Requested in #4270 ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [X] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [X] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - [X] API support added - Tests - [X] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? Requested in #4270 See merge request !6088
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/entities.rb2
-rw-r--r--lib/api/repositories.rb4
2 files changed, 4 insertions, 2 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 1942aeea656..8f1aaaaaaa0 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -159,7 +159,7 @@ module API
end
class RepoTreeObject < Grape::Entity
- expose :id, :name, :type
+ expose :id, :name, :type, :path
expose :mode do |obj, options|
filemode = obj.mode.to_s(8)
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index f55aceed92c..0bb2f74809a 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -21,16 +21,18 @@ module API
# Parameters:
# id (required) - The ID of a project
# ref_name (optional) - The name of a repository branch or tag, if not given the default branch is used
+ # recursive (optional) - Used to get a recursive tree
# Example Request:
# GET /projects/:id/repository/tree
get ':id/repository/tree' do
ref = params[:ref_name] || user_project.try(:default_branch) || 'master'
path = params[:path] || nil
+ recursive = to_boolean(params[:recursive])
commit = user_project.commit(ref)
not_found!('Tree') unless commit
- tree = user_project.repository.tree(commit.id, path)
+ tree = user_project.repository.tree(commit.id, path, recursive: recursive)
present tree.sorted_entries, with: Entities::RepoTreeObject
end