From 0c22698bd4dbe7d0d3e4a6c8bc946ac6f5de1c12 Mon Sep 17 00:00:00 2001 From: Ahmad Sherif Date: Thu, 12 May 2016 22:48:09 +0200 Subject: Add API endpoints for un/subscribing from/to a label Closes #15638 --- lib/api/helpers.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 40c967453fb..5e638dbe16a 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -95,6 +95,17 @@ module API end end + def find_project_label(id) + label = user_project.labels.find_by_id(id) || user_project.labels.find_by_title(id) + label || not_found!('Label') + end + + def find_project_issue(id) + issue = user_project.issues.find(id) + not_found! unless can?(current_user, :read_issue, issue) + issue + end + def paginate(relation) relation.page(params[:page]).per(params[:per_page].to_i).tap do |data| add_pagination_headers(data) -- cgit v1.2.1 From f5a0ac0fc197bae2eb5fe1045ed237cdbbaf6ea4 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Tue, 10 May 2016 23:58:06 -0300 Subject: Codestyle: make sure we have space around operators --- lib/api/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 5e638dbe16a..cadf9f98fe3 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -2,7 +2,7 @@ module API module Helpers PRIVATE_TOKEN_HEADER = "HTTP_PRIVATE_TOKEN" PRIVATE_TOKEN_PARAM = :private_token - SUDO_HEADER ="HTTP_SUDO" + SUDO_HEADER = "HTTP_SUDO" SUDO_PARAM = :sudo def parse_boolean(value) -- cgit v1.2.1 From 013bccbd93c4d44994126a52bf997ea59ffe594e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Mon, 23 May 2016 13:06:36 -0400 Subject: Enable Style/DefWithParentheses cop and fix single offense --- lib/api/helpers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index cadf9f98fe3..2aaa0557ea3 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -29,7 +29,7 @@ module API @current_user end - def sudo_identifier() + def sudo_identifier identifier ||= params[SUDO_PARAM] || env[SUDO_HEADER] # Regex for integers -- cgit v1.2.1 From 8c3ba8d6c9021f250fb1597f6b597d817af46b38 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Mon, 6 Jun 2016 13:16:30 +0200 Subject: Add workhorse controller and API helpers --- lib/api/helpers.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 2aaa0557ea3..0e47bb0b8ad 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -408,5 +408,15 @@ module API error!(errors[:access_level], 422) if errors[:access_level].any? not_found!(errors) end + + def send_git_blob(repository, blob) + env['api.format'] = :txt + content_type 'text/plain' + header *Gitlab::Workhorse.send_git_blob(repository, blob) + end + + def send_git_archive(repository, ref:, format:) + header *Gitlab::Workhorse.send_git_archive(repository, ref: ref, format: format) + end end end -- cgit v1.2.1 From 701e2df7e55113dafd48c570baad44bf7f24f863 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 10 Jun 2016 12:29:15 +0200 Subject: Satisfy Rubocop --- lib/api/helpers.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 0e47bb0b8ad..e1d3bbcc02d 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -412,11 +412,11 @@ module API def send_git_blob(repository, blob) env['api.format'] = :txt content_type 'text/plain' - header *Gitlab::Workhorse.send_git_blob(repository, blob) + header(*Gitlab::Workhorse.send_git_blob(repository, blob)) end def send_git_archive(repository, ref:, format:) - header *Gitlab::Workhorse.send_git_archive(repository, ref: ref, format: format) + header(*Gitlab::Workhorse.send_git_archive(repository, ref: ref, format: format)) end end end -- cgit v1.2.1 From a85dde9182f177cc2fdabd90ccdad870bf4d84c3 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Sat, 11 Jun 2016 07:16:32 -0700 Subject: Fix Error 500 when using closes_issues API with an external issue tracker Closes #18484 --- lib/api/helpers.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/api/helpers.rb') diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index e1d3bbcc02d..de5959e3aae 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -418,5 +418,13 @@ module API def send_git_archive(repository, ref:, format:) header(*Gitlab::Workhorse.send_git_archive(repository, ref: ref, format: format)) end + + def issue_entity(project) + if project.has_external_issue_tracker? + Entities::ExternalIssue + else + Entities::Issue + end + end end end -- cgit v1.2.1