summaryrefslogtreecommitdiff
path: root/lib/api/entities.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-04 14:46:15 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-04 14:46:15 +0200
commit97a4d8aea46fb45894f6e47597320ed2f6a12495 (patch)
tree22303017b20c8caac6ea9aa4a946b1dc96916a65 /lib/api/entities.rb
parentbacfad1c651d7b880a07f5f417ccb64693150935 (diff)
downloadgitlab-ce-97a4d8aea46fb45894f6e47597320ed2f6a12495.tar.gz
Improve code according to new gitlab_git
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/api/entities.rb')
-rw-r--r--lib/api/entities.rb21
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 4f636fc54a3..8f54d0d4d84 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -79,7 +79,16 @@ module API
end
class RepoObject < Grape::Entity
- expose :name, :commit
+ expose :name
+
+ 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
+
expose :protected do |repo, options|
if options[:project]
options[:project].protected_branch? repo.name
@@ -87,6 +96,16 @@ module API
end
end
+ class RepoTreeObject < Grape::Entity
+ expose :id, :name, :type
+
+ expose :mode do |obj, options|
+ filemode = obj.mode.to_s(8)
+ filemode = "0" + filemode if filemode.length < 6
+ filemode
+ end
+ end
+
class RepoCommit < Grape::Entity
expose :id, :short_id, :title, :author_name, :author_email, :created_at
end