diff options
author | Rebeca Méndez <scullymb@gmail.com> | 2016-08-29 17:23:40 +0200 |
---|---|---|
committer | Rebeca Méndez <scullymb@gmail.com> | 2016-11-12 10:00:39 +0100 |
commit | 5c966f70fb218d6f4de0f888733604293f36c33e (patch) | |
tree | ecb15585624aaa4c266345e5e65d447f474b817a /lib | |
parent | 6eeff67c6e03233d4480a55d05d4e0f1a88aef4c (diff) | |
download | gitlab-ce-5c966f70fb218d6f4de0f888733604293f36c33e.tar.gz |
Issue #4270: Recursive option for files through API
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | lib/api/repositories.rb | 4 |
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 |