Module: Dapp::Dapp::OptionTags
- Included in:
- Dapp::Dapp
- Defined in:
- lib/dapp/dapp/option_tags.rb
Instance Method Summary collapse
- #branch_tags ⇒ Object
- #build_tags ⇒ Object
- #ci_tags ⇒ Object
- #commit_tags ⇒ Object
- #option_tags ⇒ Object
- #plain_tags ⇒ Object
- #slug_tags ⇒ Object
- #tagging_schemes ⇒ Object
- #tags_by_scheme ⇒ Object
Instance Method Details
#branch_tags ⇒ Object
48 49 50 51 52 |
# File 'lib/dapp/dapp/option_tags.rb', line 48 def return {} unless [:tag_branch] raise Error::Dapp, code: :git_branch_without_name if (branch = git_own_repo.head_branch_name) == 'HEAD' { git_branch: [branch] } end |
#build_tags ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/dapp/dapp/option_tags.rb', line 59 def return {} unless [:tag_build_id] if ENV['GITLAB_CI'] build_id = ENV['CI_BUILD_ID'] || ENV['CI_JOB_ID'] elsif ENV['TRAVIS'] build_id = ENV['TRAVIS_BUILD_NUMBER'] else raise Error::Dapp, code: :ci_environment_required end { ci: [build_id] } end |
#ci_tags ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/dapp/dapp/option_tags.rb', line 73 def return {} unless [:tag_ci] {}.tap do || if ENV['GITLAB_CI'] if ENV['CI_BUILD_TAG'] || ENV['CI_COMMIT_TAG'] [:git_tag] = [ENV['CI_BUILD_TAG'] || ENV['CI_COMMIT_TAG']] elsif ENV['CI_BUILD_REF_NAME'] || ENV['CI_COMMIT_REF_NAME'] [:git_branch] = [ENV['CI_BUILD_REF_NAME'] || ENV['CI_COMMIT_REF_NAME']] end elsif ENV['TRAVIS'] if ENV['TRAVIS_TAG'] [:git_tag] = [ENV['TRAVIS_TAG']] elsif ENV['TRAVIS_BRANCH'] [:git_branch] = [ENV['TRAVIS_BRANCH']] end else raise Error::Dapp, code: :ci_environment_required end .delete_if { |_, | .first.nil? } end end |
#commit_tags ⇒ Object
54 55 56 57 |
# File 'lib/dapp/dapp/option_tags.rb', line 54 def return {} unless [:tag_commit] { git_commit: [git_own_repo.head_commit] } end |
#option_tags ⇒ Object
36 37 38 |
# File 'lib/dapp/dapp/option_tags.rb', line 36 def .values.flatten end |
#plain_tags ⇒ Object
44 45 46 |
# File 'lib/dapp/dapp/option_tags.rb', line 44 def { custom: [:tag_plain] } end |
#slug_tags ⇒ Object
40 41 42 |
# File 'lib/dapp/dapp/option_tags.rb', line 40 def { custom: [*[:tag], *[:tag_slug]]} end |
#tagging_schemes ⇒ Object
4 5 6 |
# File 'lib/dapp/dapp/option_tags.rb', line 4 def tagging_schemes %w(git_tag git_branch git_commit custom ci) end |
#tags_by_scheme ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dapp/dapp/option_tags.rb', line 8 def @tags_by_scheme_name ||= begin if [:custom].any? if settings.fetch("sentry", {}).fetch("detect-push-tag-usage", false) ("--tag or --tag-slug usage detected", extra: {"slug_tags" => }) end end {}.tap do || [, , ].each do || .each do |scheme, | [scheme] ||= [] [scheme] += .map(&method(:consistent_uniq_slugify)) end end [, , ].each do || .each do |scheme, | [scheme] ||= [] [scheme] += end end [:custom] = [:latest] if .values.flatten.empty? end end end |