Class: Pantograph::Actions::NumberOfCommitsAction

Inherits:
Pantograph::Action show all
Defined in:
pantograph/lib/pantograph/actions/number_of_commits.rb

Constant Summary

Constants inherited from Pantograph::Action

Pantograph::Action::AVAILABLE_CATEGORIES, Pantograph::Action::RETURN_TYPES

Documentation collapse

Class Method Summary collapse

Methods inherited from Pantograph::Action

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

Class Method Details

.authorsObject



54
55
56
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 54

def self.authors
  ['onevcat', 'samuelbeek', 'johnknapprs']
end

.available_optionsObject



32
33
34
35
36
37
38
39
40
41
42
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 32

def self.available_options
  [
    PantographCore::ConfigItem.new(
      key: :all,
      env_name: 'NUMBER_OF_COMMITS_ALL',
      optional: true,
      is_string: false,
      description: 'Returns number of all commits instead of current branch'
    )
  ]
end

.categoryObject



74
75
76
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 74

def self.category
  :source_control
end

.descriptionObject



21
22
23
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 21

def self.description
  'Return the number of commits in current git branch'
end

.detailsObject



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

def self.details
end

.example_codeObject



62
63
64
65
66
67
68
69
70
71
72
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 62

def self.example_code
  [
    '
    ENV["VERSION_NAME"] = number_of_commits
    ',
    '
    build_number = number_of_commits(all: true)
    puts build_number
    '
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



58
59
60
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 58

def self.is_supported?(platform)
  true
end

.outputObject



48
49
50
51
52
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 48

def self.output
  [
    ['NUMBER_OF_COMMITS', 'Total number of git commits']
  ]
end

.return_typeObject



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

def self.return_type
  :int
end

.return_valueObject



44
45
46
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 44

def self.return_value
  'The total number of all commits in current git branch'
end

.run(params) ⇒ Object



8
9
10
11
12
13
14
15
# File 'pantograph/lib/pantograph/actions/number_of_commits.rb', line 8

def self.run(params)
  Pantograph::Helper::Git.is_git?

  type    = params[:all] ? '--all' : 'HEAD'
  commits = Actions.sh("git rev-list #{type} --count").strip.to_i

  Actions.lane_context[:NUMBER_OF_COMMITS] = commits
end