summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Doits <markus.doits@stellenticket.de>2018-11-05 17:28:25 +0100
committerMarkus Doits <markus.doits@stellenticket.de>2018-11-07 13:05:25 +0100
commit024523a3b5385c5ee678c695de5a1aed6f537441 (patch)
tree2e304f04ae5501d6c4f683cc8f451ab32085be91
parent3aa85715dd5d1274866b32beeb903bf2a62e066e (diff)
downloadgitlab-ce-024523a3b5385c5ee678c695de5a1aed6f537441.tar.gz
one more refactor after feedback
-rw-r--r--app/models/ci/build.rb26
1 files changed, 13 insertions, 13 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index bebf356d1bf..392cf5bb721 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -317,23 +317,12 @@ module Ci
pipeline.builds.retried.where(name: self.name).count
end
- # The format of the retry option changed in GitLab 11.5. Before it was an
- # integer only, after it is a hash. New builds always created have the
- # correct format, but builds created before GitLab 11.5 and saved in
- # database still have the old integer only format. This helper method makes
- # sure that the format is always correct when accessing the retry options,
- # even on old builds.
- def sanitized_retry_option
- value = options&.[](:retry)
- value.is_a?(Integer) ? { max: value } : value
- end
-
def retries_max
- sanitized_retry_option&.[](:max) || 0
+ normalized_retry.fetch(:max, 0)
end
def retry_when
- sanitized_retry_option&.[](:when) || ['always']
+ normalized_retry.fetch(:when, ['always'])
end
def retry_failure?
@@ -904,6 +893,17 @@ module Ci
options&.dig(:environment, :url) || persisted_environment&.external_url
end
+ # The format of the retry option changed in GitLab 11.5. Before it was an
+ # integer only, after it is a hash. New builds always created have the
+ # correct format, but builds created before GitLab 11.5 and saved in
+ # database still have the old integer only format. This helper method makes
+ # sure that the format is always correct when accessing the retry options,
+ # even on old builds.
+ def normalized_retry
+ value = options[:retry]
+ value.is_a?(Integer) ? { max: value } : value.to_h
+ end
+
def build_attributes_from_config
return {} unless pipeline.config_processor