From f441436e53377f207657ac0e0e518e5ee2b33a6c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 26 May 2014 16:08:22 +0300 Subject: Add compare branches endpoint to API Signed-off-by: Dmitriy Zaporozhets --- lib/api/entities.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 457af52fe9d..eead8b18ebd 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -194,5 +194,22 @@ module API class Label < Grape::Entity expose :name end + + class RepoDiff < Grape::Entity + expose :old_path, :new_path, :a_mode, :b_mode, :diff + expose :new_file, :renamed_file, :deleted_file + end + + class Compare < Grape::Entity + expose :commit, using: Entities::RepoCommit do |compare, options| + Commit.new compare.commit + end + expose :commits, using: Entities::RepoCommit do |compare, options| + Commit.decorate compare.commits + end + expose :diffs, using: Entities::RepoDiff do |compare, options| + compare.diffs + end + end end end -- cgit v1.2.1 From 10ee137e9c13271d49d7046723b1e473d62a578f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 27 May 2014 11:16:50 +0300 Subject: Expose timeout and same_ref compare fields Signed-off-by: Dmitriy Zaporozhets --- lib/api/entities.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index eead8b18ebd..4a9220a7f49 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -210,6 +210,12 @@ module API expose :diffs, using: Entities::RepoDiff do |compare, options| compare.diffs end + + expose :compare_timeout do |compare, options| + compare.timeout + end + + expose :same, as: :compare_same_ref end end end -- cgit v1.2.1 From c7e00aca2d68a15c901506f1af4242df92670b6a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 27 May 2014 11:27:42 +0300 Subject: Better specs for Compare API Signed-off-by: Dmitriy Zaporozhets --- lib/api/entities.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/api/entities.rb') diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 4a9220a7f49..6bad6c74bca 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -202,7 +202,9 @@ module API class Compare < Grape::Entity expose :commit, using: Entities::RepoCommit do |compare, options| - Commit.new compare.commit + if compare.commit + Commit.new compare.commit + end end expose :commits, using: Entities::RepoCommit do |compare, options| Commit.decorate compare.commits -- cgit v1.2.1