diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2018-02-09 17:46:41 +0100 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2018-02-09 17:46:41 +0100 |
commit | 922d156a5e0412a12662df94e03479f7ed015f7b (patch) | |
tree | b36694ea6070ec44bf95a1d02937cda291f87e22 /lib | |
parent | 2a970e02912a75962ce559ba49252a4696bbfbea (diff) | |
download | gitlab-ce-922d156a5e0412a12662df94e03479f7ed015f7b.tar.gz |
Separate branch and tag names
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/commits.rb | 8 | ||||
-rw-r--r-- | lib/api/entities.rb | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb index 6d845253c3a..afaf68114e8 100644 --- a/lib/api/commits.rb +++ b/lib/api/commits.rb @@ -171,12 +171,12 @@ module API refs = case params[:type] when 'branches' - user_project.repository.branch_names_contains(commit.id) + user_project.repository.branch_names_contains(commit.id).map {|branch_name| [branch_name, true]} when 'tags' - user_project.repository.tag_names_contains(commit.id) + user_project.repository.tag_names_contains(commit.id).map {|tag_name| [tag_name, false]} else - refs = user_project.repository.branch_names_contains(commit.id) - refs.concat(user_project.repository.tag_names_contains(commit.id)) + refs = user_project.repository.branch_names_contains(commit.id).map {|branch_name| [branch_name, true]} + refs.concat(user_project.repository.tag_names_contains(commit.id).map {|tag_name| [tag_name, false]}) end present refs, with: Entities::BasicRef diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 054c04bbd98..c7a817877f0 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -277,8 +277,12 @@ module API end class BasicRef < Grape::Entity - expose :name do |ref, options| - ref + expose :branch_name, if: lambda { |ref, options| ref[1] } do |ref, options| + ref[0] + end + + expose :tag_name, if: lambda { |ref, options| !ref[1] } do |ref, options| + ref[0] end end |