Class: Fastlane::Actions::GitTagExistsAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/git_tag_exists.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, details, lane_context, method_missing, other_action, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



57
58
59
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 57

def self.authors
  ["antondomashnev"]
end

.available_optionsObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 28

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :tag,
                                 description: "The tag name that should be checked"),
    FastlaneCore::ConfigItem.new(key: :remote,
                                 description: "Whether to check remote. Defaults to `false`",
                                 type: Boolean,
                                 default_value: false,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :remote_name,
                                 description: "The remote to check. Defaults to `origin`",
                                 default_value: 'origin',
                                 optional: true)
  ]
end

.categoryObject



73
74
75
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 73

def self.category
  :source_control
end

.descriptionObject



24
25
26
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 24

def self.description
  "Checks if the git tag with the given name exists in the current repo"
end

.example_codeObject



65
66
67
68
69
70
71
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 65

def self.example_code
  [
    'if git_tag_exists(tag: "1.1.0")
      UI.message("Found it 🚀")
    end'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



61
62
63
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 61

def self.is_supported?(platform)
  true
end

.outputObject



52
53
54
55
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 52

def self.output
  [
  ]
end

.return_typeObject



48
49
50
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 48

def self.return_type
  :bool
end

.return_valueObject



44
45
46
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 44

def self.return_value
  "Boolean value whether the tag exists or not"
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'fastlane/lib/fastlane/actions/git_tag_exists.rb', line 4

def self.run(params)
  tag_ref = "refs/tags/#{params[:tag].shellescape}"
  if params[:remote]
    command = "git ls-remote -q --exit-code #{params[:remote_name].shellescape} #{tag_ref}"
  else
    command = "git rev-parse -q --verify #{tag_ref}"
  end
  exists = true
  Actions.sh(
    command,
    log: FastlaneCore::Globals.verbose?,
    error_callback: ->(result) { exists = false }
  )
  exists
end