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
- #git_local_repo ⇒ Object
- #option_tags ⇒ Object
- #simple_tags ⇒ Object
- #tagging_schemes ⇒ Object
- #tags_by_scheme ⇒ Object
Instance Method Details
#branch_tags ⇒ Object
33 34 35 36 37 |
# File 'lib/dapp/dapp/option_tags.rb', line 33 def return {} unless [:tag_branch] raise Error::Dapp, code: :git_branch_without_name if (branch = git_local_repo.branch) == 'HEAD' { git_branch: [branch] } end |
#build_tags ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/dapp/dapp/option_tags.rb', line 44 def return {} unless [:tag_build_id] if ENV['GITLAB_CI'] build_id = ENV['CI_BUILD_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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/dapp/dapp/option_tags.rb', line 58 def return {} unless [:tag_ci] {}.tap do || if ENV['GITLAB_CI'] [:git_branch] = [ENV['CI_BUILD_REF_NAME']] [:git_tag] = [ENV['CI_BUILD_TAG']] elsif ENV['TRAVIS'] [:git_branch] = [ENV['TRAVIS_BRANCH']] [:git_tag] = [ENV['TRAVIS_TAG']] else raise Error::Dapp, code: :ci_environment_required end .delete_if { |_, | .first.nil? } end end |
#commit_tags ⇒ Object
39 40 41 42 |
# File 'lib/dapp/dapp/option_tags.rb', line 39 def return {} unless [:tag_commit] { git_commit: [git_local_repo.latest_commit] } end |
#git_local_repo ⇒ Object
4 5 6 |
# File 'lib/dapp/dapp/option_tags.rb', line 4 def git_local_repo @git_repo ||= ::Dapp::Dimg::GitRepo::Own.new(self) end |
#option_tags ⇒ Object
25 26 27 |
# File 'lib/dapp/dapp/option_tags.rb', line 25 def .values.flatten end |
#simple_tags ⇒ Object
29 30 31 |
# File 'lib/dapp/dapp/option_tags.rb', line 29 def { custom: [:tag] } end |
#tagging_schemes ⇒ Object
8 9 10 |
# File 'lib/dapp/dapp/option_tags.rb', line 8 def tagging_schemes %w(git_tag git_branch git_commit custom ci) end |
#tags_by_scheme ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dapp/dapp/option_tags.rb', line 12 def @tags_by_scheme_name ||= begin [, , , , ].reduce({}) do |, | .in_depth_merge() end.tap do || [:git_branch, :git_tag].each do |scheme| [scheme].map!(&method(:consistent_uniq_slugify)) unless [scheme].nil? end [:custom] = [:latest] if .values.flatten.empty? end end end |