diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-30 16:17:36 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-10-30 16:17:36 +0200 |
commit | f0dd16d53e81bb0796fa6fa422efcab8a64f097a (patch) | |
tree | 8d583e1e96b1e82334d185d9252e22842fe36689 /lib | |
parent | 8388bbe82918d2fca2600620f48e048ccfab2c97 (diff) | |
parent | c2f0ae8a40658d02dfa128881a014fe1e907f61c (diff) | |
download | gitlab-ce-f0dd16d53e81bb0796fa6fa422efcab8a64f097a.tar.gz |
Merge branch 'master' of github.com:gitlabhq/gitlabhq
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Conflicts:
CHANGELOG
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/entities.rb | 19 | ||||
-rw-r--r-- | lib/api/repositories.rb | 5 |
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 80e9470195e..d19caf5b23a 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -73,6 +73,25 @@ module API end end + class RepoTag < Grape::Entity + expose :name + expose :message do |repo_obj, _options| + if repo_obj.respond_to?(:message) + repo_obj.message + else + nil + end + end + + expose :commit do |repo_obj, options| + if repo_obj.respond_to?(:commit) + repo_obj.commit + elsif options[:project] + options[:project].repository.commit(repo_obj.target) + end + end + end + class RepoObject < Grape::Entity expose :name diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index 626d99c2649..a1a7721b288 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -23,7 +23,8 @@ module API # Example Request: # GET /projects/:id/repository/tags get ":id/repository/tags" do - present user_project.repo.tags.sort_by(&:name).reverse, with: Entities::RepoObject, project: user_project + present user_project.repo.tags.sort_by(&:name).reverse, + with: Entities::RepoTag, project: user_project end # Create tag @@ -43,7 +44,7 @@ module API if result[:status] == :success present result[:tag], - with: Entities::RepoObject, + with: Entities::RepoTag, project: user_project else render_api_error!(result[:message], 400) |