diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-07-21 01:24:05 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-07-21 01:24:05 +0800 |
commit | e5b05fe8c0e773d850c314b8317e5fa2eb75379d (patch) | |
tree | 93d05868c60cd3b3316f63f54881abc07561b6e8 /lib/api | |
parent | 122b046b92573f3e1db579b5ff73fa3bdfffc124 (diff) | |
parent | b4717017e7ad601eaa1d53c9238a242c7fdf0daa (diff) | |
download | gitlab-ce-e5b05fe8c0e773d850c314b8317e5fa2eb75379d.tar.gz |
Merge branch 'master' into artifacts-from-ref-and-build-name-api
* master: (261 commits)
Add link to user profile to commit avatar (!5163)
Refactor service settings view
Fix a problem with processing a pipeline where stage only has manual actions
A CHANGELOG entry
Don't show other actions of the same name
Use limit parameter rather than hardcoded value
Remove icons from explore nav
Change how we style redirect_to
Use flash[:notice] only
Create PipelinesSettingsController for showing settings page
Fix a few nitpicks
Allow to disable user request access to groups/projects
Enable Style/MultilineTernaryOperator rubocop cop
Fix review comments
Update routes
Update CHANGELOG
Improve implementation of variables
Log cron_jobs configuration instead of raising exception
Added checks for migration downtime
Ensure to_json methods take optional argument
...
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/commit_statuses.rb | 2 | ||||
-rw-r--r-- | lib/api/helpers.rb | 6 | ||||
-rw-r--r-- | lib/api/merge_requests.rb | 2 | ||||
-rw-r--r-- | lib/api/projects.rb | 2 |
4 files changed, 4 insertions, 8 deletions
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb index acb4812b5cf..4df6ca8333e 100644 --- a/lib/api/commit_statuses.rb +++ b/lib/api/commit_statuses.rb @@ -24,7 +24,7 @@ module API pipelines = user_project.pipelines.where(sha: params[:sha]) statuses = ::CommitStatus.where(pipeline: pipelines) - statuses = statuses.latest unless parse_boolean(params[:all]) + statuses = statuses.latest unless to_boolean(params[:all]) statuses = statuses.where(ref: params[:ref]) if params[:ref].present? statuses = statuses.where(stage: params[:stage]) if params[:stage].present? statuses = statuses.where(name: params[:name]) if params[:name].present? diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index d6e4eb2afd7..130509cdad6 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -5,10 +5,6 @@ module API SUDO_HEADER = "HTTP_SUDO" SUDO_PARAM = :sudo - def parse_boolean(value) - [ true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON' ].include?(value) - end - def to_boolean(value) return true if value =~ /^(true|t|yes|y|1|on)$/i return false if value =~ /^(false|f|no|n|0|off)$/i @@ -297,7 +293,7 @@ module API def filter_projects(projects) # If the archived parameter is passed, limit results accordingly if params[:archived].present? - projects = projects.where(archived: parse_boolean(params[:archived])) + projects = projects.where(archived: to_boolean(params[:archived])) end if params[:search].present? diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 4fcdf8968c9..2b685621da9 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -242,7 +242,7 @@ module API should_remove_source_branch: params[:should_remove_source_branch] } - if parse_boolean(params[:merge_when_build_succeeds]) && merge_request.pipeline && merge_request.pipeline.active? + if to_boolean(params[:merge_when_build_succeeds]) && merge_request.pipeline && merge_request.pipeline.active? ::MergeRequests::MergeWhenBuildSucceedsService.new(merge_request.target_project, current_user, merge_params). execute(merge_request) else diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 6d2a6f3946c..8fed7db8803 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -8,7 +8,7 @@ module API def map_public_to_visibility_level(attrs) publik = attrs.delete(:public) if publik.present? && !attrs[:visibility_level].present? - publik = parse_boolean(publik) + publik = to_boolean(publik) # Since setting the public attribute to private could mean either # private or internal, use the more conservative option, private. attrs[:visibility_level] = (publik == true) ? Gitlab::VisibilityLevel::PUBLIC : Gitlab::VisibilityLevel::PRIVATE |