summaryrefslogtreecommitdiff
path: root/lib/gitlab/badge/pipeline
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /lib/gitlab/badge/pipeline
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
downloadgitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'lib/gitlab/badge/pipeline')
-rw-r--r--lib/gitlab/badge/pipeline/status.rb8
-rw-r--r--lib/gitlab/badge/pipeline/template.rb14
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/gitlab/badge/pipeline/status.rb b/lib/gitlab/badge/pipeline/status.rb
index a403d839517..17f179f027d 100644
--- a/lib/gitlab/badge/pipeline/status.rb
+++ b/lib/gitlab/badge/pipeline/status.rb
@@ -7,11 +7,15 @@ module Gitlab
# Pipeline status badge
#
class Status < Badge::Base
- attr_reader :project, :ref
+ attr_reader :project, :ref, :customization
- def initialize(project, ref)
+ def initialize(project, ref, opts: {})
@project = project
@ref = ref
+ @customization = {
+ key_width: opts[:key_width].to_i,
+ key_text: opts[:key_text]
+ }
@sha = @project.commit(@ref).try(:sha)
end
diff --git a/lib/gitlab/badge/pipeline/template.rb b/lib/gitlab/badge/pipeline/template.rb
index 0d3d44135e7..781897fab4b 100644
--- a/lib/gitlab/badge/pipeline/template.rb
+++ b/lib/gitlab/badge/pipeline/template.rb
@@ -24,10 +24,16 @@ module Gitlab
def initialize(badge)
@entity = badge.entity
@status = badge.status
+ @key_text = badge.customization.dig(:key_text)
+ @key_width = badge.customization.dig(:key_width)
end
def key_text
- @entity.to_s
+ if @key_text && @key_text.size <= MAX_KEY_SIZE
+ @key_text
+ else
+ @entity.to_s
+ end
end
def value_text
@@ -35,7 +41,11 @@ module Gitlab
end
def key_width
- 62
+ if @key_width && @key_width.between?(1, MAX_KEY_SIZE)
+ @key_width
+ else
+ 62
+ end
end
def value_width