From 53bf52f191612df92d993cbcd3c4d6c89ab9c95a Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Fri, 14 Nov 2014 18:23:55 +0200 Subject: Better message for failed pushes because of git hooks Conflicts: lib/gitlab/git_access.rb spec/lib/gitlab/git_access_spec.rb --- lib/api/internal.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index ebf2296097d..1648834f034 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -43,7 +43,7 @@ module API return false unless actor - access.allowed?( + access.check( actor, params[:action], project, -- cgit v1.2.1 From 612b8806ddc7881421e26a9dbfe465d6445fb3d6 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 1 Dec 2014 16:55:33 +0200 Subject: Fix internal API for missing project or key Signed-off-by: Dmitriy Zaporozhets --- lib/api/internal.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 1648834f034..180e50611cf 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -33,15 +33,20 @@ module API end project = Project.find_with_namespace(project_path) - return false unless project + + unless project + return Gitlab::GitAccessStatus.new(false, 'No such project') + end actor = if params[:key_id] - Key.find(params[:key_id]) + Key.find_by(id: params[:key_id]) elsif params[:user_id] - User.find(params[:user_id]) + User.find_by(id: params[:user_id]) end - return false unless actor + unless actor + return Gitlab::GitAccessStatus.new(false, 'No such user or key') + end access.check( actor, -- cgit v1.2.1 From cd688a60111853f63413a87ad6632ad57368e886 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sun, 19 Oct 2014 16:09:38 +0200 Subject: Replace regex methods by string ones since faster and more readable. --- lib/api/internal.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 180e50611cf..a999cff09c0 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -25,8 +25,8 @@ module API # project. This applies the correct project permissions to # the wiki repository as well. access = - if project_path =~ /\.wiki\Z/ - project_path.sub!(/\.wiki\Z/, '') + if project_path.end_with?('.wiki') + project_path.chomp!('.wiki') Gitlab::GitAccessWiki.new else Gitlab::GitAccess.new -- cgit v1.2.1 From da884aabc7674c68eee23699efb357bc94aef8d3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:22:57 -0800 Subject: Avoid using {...} for multi-line blocks --- lib/api/internal.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index a999cff09c0..7a89a26facc 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -1,9 +1,7 @@ module API # Internal access API class Internal < Grape::API - before { - authenticate_by_gitlab_shell_token! - } + before { authenticate_by_gitlab_shell_token! } namespace 'internal' do # Check if git command is allowed to project -- cgit v1.2.1 From 42422dcc6aab156cc3e89c75c7ed2a71c715b169 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Sat, 7 Feb 2015 16:41:30 +0100 Subject: Add internal broadcast message API. --- lib/api/internal.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 7a89a26facc..b5542c1874b 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -69,6 +69,14 @@ module API gitlab_rev: Gitlab::REVISION, } end + + get "/broadcast_message" do + if message = BroadcastMessage.current + present message, with: Entities::BroadcastMessage + else + not_found! + end + end end end end -- cgit v1.2.1 From 833d4dddf2fc3a933a28b4deb60ef6a3dc7eb0fb Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 18 Feb 2015 14:34:05 -0800 Subject: Dont send 404 if no broadcast messages now because it flood gitlab-shell logs with 404 errors :( --- lib/api/internal.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index b5542c1874b..04ff049989b 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -73,8 +73,6 @@ module API get "/broadcast_message" do if message = BroadcastMessage.current present message, with: Entities::BroadcastMessage - else - not_found! end end end -- cgit v1.2.1 From 558dd811971776fc4a921b79296f5d792b245686 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 18 Feb 2015 14:58:20 -0800 Subject: Improve broadcast message API --- lib/api/internal.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 04ff049989b..ba3fe619b92 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -73,6 +73,8 @@ module API get "/broadcast_message" do if message = BroadcastMessage.current present message, with: Entities::BroadcastMessage + else + {} end end end -- cgit v1.2.1