Replace parse_boolean with to_boolean
This commit is contained in:
parent
1cd573ee7f
commit
839aec1a61
4 changed files with 4 additions and 8 deletions
|
@ -24,7 +24,7 @@ module API
|
||||||
|
|
||||||
pipelines = user_project.pipelines.where(sha: params[:sha])
|
pipelines = user_project.pipelines.where(sha: params[:sha])
|
||||||
statuses = ::CommitStatus.where(pipeline: pipelines)
|
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(ref: params[:ref]) if params[:ref].present?
|
||||||
statuses = statuses.where(stage: params[:stage]) if params[:stage].present?
|
statuses = statuses.where(stage: params[:stage]) if params[:stage].present?
|
||||||
statuses = statuses.where(name: params[:name]) if params[:name].present?
|
statuses = statuses.where(name: params[:name]) if params[:name].present?
|
||||||
|
|
|
@ -5,10 +5,6 @@ module API
|
||||||
SUDO_HEADER = "HTTP_SUDO"
|
SUDO_HEADER = "HTTP_SUDO"
|
||||||
SUDO_PARAM = :sudo
|
SUDO_PARAM = :sudo
|
||||||
|
|
||||||
def parse_boolean(value)
|
|
||||||
[ true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON' ].include?(value)
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_boolean(value)
|
def to_boolean(value)
|
||||||
return true if value =~ /^(true|t|yes|y|1|on)$/i
|
return true if value =~ /^(true|t|yes|y|1|on)$/i
|
||||||
return false if value =~ /^(false|f|no|n|0|off)$/i
|
return false if value =~ /^(false|f|no|n|0|off)$/i
|
||||||
|
@ -297,7 +293,7 @@ module API
|
||||||
def filter_projects(projects)
|
def filter_projects(projects)
|
||||||
# If the archived parameter is passed, limit results accordingly
|
# If the archived parameter is passed, limit results accordingly
|
||||||
if params[:archived].present?
|
if params[:archived].present?
|
||||||
projects = projects.where(archived: parse_boolean(params[:archived]))
|
projects = projects.where(archived: to_boolean(params[:archived]))
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:search].present?
|
if params[:search].present?
|
||||||
|
|
|
@ -242,7 +242,7 @@ module API
|
||||||
should_remove_source_branch: params[:should_remove_source_branch]
|
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).
|
::MergeRequests::MergeWhenBuildSucceedsService.new(merge_request.target_project, current_user, merge_params).
|
||||||
execute(merge_request)
|
execute(merge_request)
|
||||||
else
|
else
|
||||||
|
|
|
@ -8,7 +8,7 @@ module API
|
||||||
def map_public_to_visibility_level(attrs)
|
def map_public_to_visibility_level(attrs)
|
||||||
publik = attrs.delete(:public)
|
publik = attrs.delete(:public)
|
||||||
if publik.present? && !attrs[:visibility_level].present?
|
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
|
# Since setting the public attribute to private could mean either
|
||||||
# private or internal, use the more conservative option, private.
|
# private or internal, use the more conservative option, private.
|
||||||
attrs[:visibility_level] = (publik == true) ? Gitlab::VisibilityLevel::PUBLIC : Gitlab::VisibilityLevel::PRIVATE
|
attrs[:visibility_level] = (publik == true) ? Gitlab::VisibilityLevel::PUBLIC : Gitlab::VisibilityLevel::PRIVATE
|
||||||
|
|
Loading…
Reference in a new issue