Class: Fastlane::Actions::NumberOfCommitsAction

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

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES

Documentation collapse

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, available_options, lane_context, method_missing, other_action, output, sample_return_value, sh, step_text

Class Method Details

.authorsObject



36
37
38
# File 'lib/fastlane/actions/number_of_commits.rb', line 36

def self.authors
  ["onevcat"]
end

.categoryObject



51
52
53
# File 'lib/fastlane/actions/number_of_commits.rb', line 51

def self.category
  :source_control
end

.descriptionObject



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

def self.description
  "Return the total number of all commits in current git repo"
end

.detailsObject



32
33
34
# File 'lib/fastlane/actions/number_of_commits.rb', line 32

def self.details
  "You can use this action to get the number of commits of this repo. This is useful if you want to set the build number to the number of commits."
end

.example_codeObject



44
45
46
47
48
49
# File 'lib/fastlane/actions/number_of_commits.rb', line 44

def self.example_code
  [
    'build_number = number_of_commits
    increment_build_number(build_number: build_number)'
  ]
end

.is_git?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
# File 'lib/fastlane/actions/number_of_commits.rb', line 4

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/fastlane/actions/number_of_commits.rb', line 40

def self.is_supported?(platform)
  true
end

.return_valueObject



28
29
30
# File 'lib/fastlane/actions/number_of_commits.rb', line 28

def self.return_value
  "The total number of all commits in current git repo"
end

.run(params) ⇒ Object



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

def self.run(params)
  if is_git?
    command = 'git rev-list HEAD --count'
  else
    UI.user_error!("Not in a git repository.")
  end
  return Actions.sh(command).strip.to_i
end