Class: Fastlane::Actions::SetBuildNumberRepositoryAction

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

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, return_value, sh, step_text

Class Method Details

.authorsObject



89
90
91
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 89

def self.authors
  ["pbrooks", "armadsen"]
end

.available_optionsObject



73
74
75
76
77
78
79
80
81
82
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 73

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :use_hg_revision_number,
                                 env_name: "USE_HG_REVISION_NUMBER",
                                 description: "Use hg revision number instead of hash (ignored for non-hg repos)",
                                 optional: true,
                                 is_string: false,
                                 default_value: false)
  ]
end

.descriptionObject



69
70
71
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 69

def self.description
  "Set the build number from the current repository"
end

.is_git?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 18

def self.is_git?
  Actions.sh 'git rev-parse HEAD'
  return true
rescue
  return false
end

.is_git_svn?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 25

def self.is_git_svn?
  Actions.sh 'git svn info'
  return true
rescue
  return false
end

.is_hg?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 32

def self.is_hg?
  Actions.sh 'hg status'
  return true
rescue
  return false
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 7

def self.is_supported?(platform)
  [:ios, :mac].include? platform
end

.is_svn?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 11

def self.is_svn?
  Actions.sh 'svn info'
  return true
rescue
  return false
end

.outputObject



84
85
86
87
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 84

def self.output
  [
  ]
end

.run(params) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fastlane/actions/set_build_number_repository.rb', line 39

def self.run(params)
  if is_svn?
    Helper.log.info "Detected repo: svn"
    command = 'svn info | grep Revision | egrep -o "[0-9]+"'
  elsif is_git_svn?
    Helper.log.info "Detected repo: git-svn"
    command = 'git svn info | grep Revision | egrep -o "[0-9]+"'
  elsif is_git?
    Helper.log.info "Detected repo: git"
    command = 'git rev-parse --short HEAD'
  elsif is_hg?
    Helper.log.info "Detected repo: hg"
    if params[:use_hg_revision_number]
      command = 'hg parent --template {rev}'
    else
      command = 'hg parent --template "{node|short}"'
    end
  else
    raise "No repository detected"
  end

  build_number = Actions.sh command

  Fastlane::Actions::IncrementBuildNumberAction.run(build_number: build_number)
end