summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2018-02-09 14:30:27 +0100
committerRobert Schilling <rschilling@student.tugraz.at>2018-02-09 14:59:47 +0100
commit4cefb568d96c4868404caa14534a4329e2dd887f (patch)
tree11f77a4974d2599cc7f9655dffa5193e0100581b
parent2bbf75f2114530f499bb1a917f000c7605d147f1 (diff)
downloadgitlab-ce-4cefb568d96c4868404caa14534a4329e2dd887f.tar.gz
Incorporate feedback
-rw-r--r--lib/api/commits.rb29
-rw-r--r--lib/api/entities.rb10
2 files changed, 18 insertions, 21 deletions
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index 3cf88551fa7..6d845253c3a 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -156,29 +156,30 @@ module API
end
end
- desc 'Get all reference a commit is pushed to' do
+ desc 'Get all references a commit is pushed to' do
detail 'This feature was introduced in GitLab 10.6'
- success Entities::SimpleRef
+ success Entities::BasicRef
end
params do
requires :sha, type: String, desc: 'A commit sha'
- optional :type, type: String, values: %w(branches tags all), default: 'all', desc: 'Scope'
+ optional :type, type: String, values: %w[branches tags all], default: 'all', desc: 'Scope'
end
get ':id/repository/commits/:sha/refs', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
not_found!('Commit') unless commit
- case params[:type]
- when 'branches'
- refs = user_project.repository.branch_names_contains(commit.id)
- when 'tags'
- refs = user_project.repository.tag_names_contains(commit.id)
- else
- refs = user_project.repository.branch_names_contains(commit.id)
- refs.push(*user_project.repository.tag_names_contains(commit.id))
- end
+ refs =
+ case params[:type]
+ when 'branches'
+ user_project.repository.branch_names_contains(commit.id)
+ when 'tags'
+ user_project.repository.tag_names_contains(commit.id)
+ else
+ refs = user_project.repository.branch_names_contains(commit.id)
+ refs.concat(user_project.repository.tag_names_contains(commit.id))
+ end
- present refs, with: Entities::SimpleRef
+ present refs, with: Entities::BasicRef
end
desc 'Post comment to commit' do
@@ -190,7 +191,7 @@ module API
optional :path, type: String, desc: 'The file path'
given :path do
requires :line, type: Integer, desc: 'The line number'
- requires :line_type, type: String, values: %w(new old), default: 'new', desc: 'The type of the line'
+ requires :line_type, type: String, values: %w[new old], default: 'new', desc: 'The type of the line'
end
end
post ':id/repository/commits/:sha/comments', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index e8c9ba6fce5..054c04bbd98 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -277,16 +277,12 @@ module API
end
class BasicRef < Grape::Entity
- expose :name
- end
-
- class SimpleRef < Grape::Entity
expose :name do |ref, options|
ref
end
end
- class Branch < BasicRef
+ class Branch < Grape::Entity
expose :name
expose :commit, using: Entities::Commit do |repo_branch, options|
@@ -855,8 +851,8 @@ module API
expose :description
end
- class Tag < BasicRef
- expose :message
+ class Tag < Grape::Entity
+ expose :name, :message
expose :commit, using: Entities::Commit do |repo_tag, options|
options[:project].repository.commit(repo_tag.dereferenced_target)