pantograph 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/pantograph/lib/assets/custom_action_template.rb +18 -14
  4. data/pantograph/lib/pantograph/action.rb +1 -1
  5. data/pantograph/lib/pantograph/action_collector.rb +1 -1
  6. data/pantograph/lib/pantograph/actions/actions_helper.rb +2 -2
  7. data/pantograph/lib/pantograph/actions/bundle_install.rb +120 -84
  8. data/pantograph/lib/pantograph/actions/cloc.rb +64 -49
  9. data/pantograph/lib/pantograph/actions/create_pull_request.rb +1 -1
  10. data/pantograph/lib/pantograph/actions/danger.rb +103 -82
  11. data/pantograph/lib/pantograph/actions/debug.rb +2 -2
  12. data/pantograph/lib/pantograph/actions/default_platform.rb +5 -3
  13. data/pantograph/lib/pantograph/actions/download.rb +10 -9
  14. data/pantograph/lib/pantograph/actions/echo.rb +1 -1
  15. data/pantograph/lib/pantograph/actions/ensure_bundle_exec.rb +18 -10
  16. data/pantograph/lib/pantograph/actions/ensure_env_vars.rb +16 -17
  17. data/pantograph/lib/pantograph/actions/ensure_git_branch.rb +14 -14
  18. data/pantograph/lib/pantograph/actions/ensure_git_status_clean.rb +18 -34
  19. data/pantograph/lib/pantograph/actions/get_github_release.rb +1 -1
  20. data/pantograph/lib/pantograph/actions/git_branch.rb +6 -7
  21. data/pantograph/lib/pantograph/actions/git_commit.rb +21 -13
  22. data/pantograph/lib/pantograph/actions/git_pull.rb +4 -23
  23. data/pantograph/lib/pantograph/actions/git_pull_tags.rb +31 -0
  24. data/pantograph/lib/pantograph/actions/git_submodule_update.rb +23 -16
  25. data/pantograph/lib/pantograph/actions/git_tag_exists.rb +21 -25
  26. data/pantograph/lib/pantograph/actions/gradle.rb +82 -58
  27. data/pantograph/lib/pantograph/actions/import.rb +1 -1
  28. data/pantograph/lib/pantograph/actions/import_from_git.rb +48 -31
  29. data/pantograph/lib/pantograph/actions/is_ci.rb +1 -1
  30. data/pantograph/lib/pantograph/actions/is_verbose.rb +77 -0
  31. data/pantograph/lib/pantograph/actions/jira.rb +50 -55
  32. data/pantograph/lib/pantograph/actions/lane_context.rb +6 -6
  33. data/pantograph/lib/pantograph/actions/last_git_commit.rb +3 -3
  34. data/pantograph/lib/pantograph/actions/min_pantograph_version.rb +19 -25
  35. data/pantograph/lib/pantograph/actions/number_of_commits.rb +34 -30
  36. data/pantograph/lib/pantograph/actions/opt_out_usage.rb +15 -9
  37. data/pantograph/lib/pantograph/actions/pantograph_version.rb +2 -2
  38. data/pantograph/lib/pantograph/actions/println.rb +1 -1
  39. data/pantograph/lib/pantograph/actions/prompt.rb +31 -22
  40. data/pantograph/lib/pantograph/actions/prompt_secure.rb +128 -0
  41. data/pantograph/lib/pantograph/actions/reset_git_repo.rb +1 -1
  42. data/pantograph/lib/pantograph/actions/set_github_release.rb +4 -4
  43. data/pantograph/lib/pantograph/actions/sh.rb +3 -3
  44. data/pantograph/lib/pantograph/commands_generator.rb +1 -1
  45. data/pantograph/lib/pantograph/helper/git_helper.rb +29 -0
  46. data/pantograph/lib/pantograph/lane_manager.rb +1 -1
  47. data/pantograph/lib/pantograph/pant_file.rb +22 -16
  48. data/pantograph/lib/pantograph/plugins/template/README.md.erb +1 -1
  49. data/pantograph/lib/pantograph/setup/setup.rb +6 -17
  50. data/pantograph/lib/pantograph/version.rb +1 -1
  51. data/pantograph_core/lib/pantograph_core/configuration/commander_generator.rb +1 -1
  52. data/pantograph_core/lib/pantograph_core/globals.rb +1 -2
  53. data/pantograph_core/lib/pantograph_core/helper.rb +19 -6
  54. data/pantograph_core/lib/pantograph_core/ui/implementations/shell.rb +1 -4
  55. metadata +19 -5
  56. data/pantograph/lib/pantograph/actions/git_add.rb +0 -93
  57. data/pantograph/lib/pantograph/actions/make_changelog_from_jenkins.rb +0 -81
  58. data/pantograph/lib/pantograph/actions/nexus_upload.rb +0 -230
@@ -2,30 +2,28 @@ module Pantograph
2
2
  module Actions
3
3
  class DangerAction < Action
4
4
  def self.run(params)
5
- Actions.verify_gem!('danger')
6
- cmd = []
5
+ ENV['DANGER_GITHUB_API_TOKEN'] = params[:github_api_token] if params[:github_api_token]
7
6
 
8
- cmd << 'bundle exec' if params[:use_bundle_exec] && shell_out_should_use_bundle_exec?
9
- cmd << 'danger'
10
- cmd << '--verbose' if params[:verbose]
7
+ danger_cmd = []
11
8
 
12
- danger_id = params[:danger_id]
13
- dangerfile = params[:dangerfile]
14
- base = params[:base]
15
- head = params[:head]
16
- pr = params[:pr]
17
- cmd << "--danger_id=#{danger_id}" if danger_id
18
- cmd << "--dangerfile=#{dangerfile}" if dangerfile
19
- cmd << "--fail-on-errors=true" if params[:fail_on_errors]
20
- cmd << "--new-comment" if params[:new_comment]
21
- cmd << "--remove-previous-comments" if params[:remove_previous_comments]
22
- cmd << "--base=#{base}" if base
23
- cmd << "--head=#{head}" if head
24
- cmd << "pr #{pr}" if pr
9
+ if params[:use_bundle_exec] && shell_out_should_use_bundle_exec?
10
+ danger_cmd << 'bundle exec'
11
+ end
25
12
 
26
- ENV['DANGER_GITHUB_API_TOKEN'] = params[:github_api_token] if params[:github_api_token]
13
+ danger_cmd << 'danger'
14
+ danger_cmd << "--dangerfile=#{params[:dangerfile]}"
15
+ danger_cmd << "--new-comment" if params[:new_comment]
16
+ danger_cmd << "--remove-previous-comments" if params[:remove_previous_comments]
17
+ danger_cmd << "--base=#{params[:base]}" if params[:base]
18
+ danger_cmd << "--head=#{params[:head]}" if params[:head]
19
+ danger_cmd << "pr #{params[:pr]}" if params[:pr]
20
+ danger_cmd << "--danger_id=#{params[:danger_id]}" if params[:danger_id]
21
+ danger_cmd << '--verbose' if params[:verbose]
22
+
23
+ danger_cmd << "--fail-on-errors=#{params[:fail_on_errors]}"
24
+ danger_cmd = danger_cmd.join(' ')
27
25
 
28
- Actions.sh(cmd.join(' '))
26
+ Actions.sh(danger_cmd)
29
27
  end
30
28
 
31
29
  def self.description
@@ -34,72 +32,95 @@ module Pantograph
34
32
 
35
33
  def self.details
36
34
  [
37
- 'Formalize your Pull Request etiquette.',
35
+ 'Stop Saying your Forgot in Source Control',
38
36
  'More information: [https://github.com/danger/danger](https://github.com/danger/danger).'
39
37
  ].join("\n")
40
38
  end
41
39
 
42
40
  def self.available_options
43
41
  [
44
- PantographCore::ConfigItem.new(key: :use_bundle_exec,
45
- env_name: 'DANGER_USE_BUNDLE_EXEC',
46
- description: 'Use bundle exec when there is a Gemfile presented',
47
- is_string: false,
48
- default_value: true),
49
- PantographCore::ConfigItem.new(key: :verbose,
50
- env_name: 'DANGER_VERBOSE',
51
- description: 'Show more debugging information',
52
- is_string: false,
53
- default_value: false),
54
- PantographCore::ConfigItem.new(key: :danger_id,
55
- env_name: 'DANGER_ID',
56
- description: 'The identifier of this Danger instance',
57
- type: String,
58
- optional: true),
59
- PantographCore::ConfigItem.new(key: :dangerfile,
60
- env_name: 'DANGER_DANGERFILE',
61
- description: 'The location of your Dangerfile',
62
- type: String,
63
- optional: true),
64
- PantographCore::ConfigItem.new(key: :github_api_token,
65
- env_name: 'DANGER_GITHUB_API_TOKEN',
66
- description: 'GitHub API token for danger',
67
- sensitive: true,
68
- type: String,
69
- optional: true),
70
- PantographCore::ConfigItem.new(key: :fail_on_errors,
71
- env_name: 'DANGER_FAIL_ON_ERRORS',
72
- description: 'Should always fail the build process, defaults to false',
73
- is_string: false,
74
- optional: true,
75
- default_value: false),
76
- PantographCore::ConfigItem.new(key: :new_comment,
77
- env_name: 'DANGER_NEW_COMMENT',
78
- description: 'Makes Danger post a new comment instead of editing its previous one',
79
- is_string: false,
80
- optional: true,
81
- default_value: false),
82
- PantographCore::ConfigItem.new(key: :remove_previous_comments,
83
- env_name: 'DANGER_REMOVE_PREVIOUS_COMMENT',
84
- description: 'Makes Danger remove all previous comment and create a new one in the end of the list',
85
- is_string: false,
86
- optional: true,
87
- default_value: false),
88
- PantographCore::ConfigItem.new(key: :base,
89
- env_name: 'DANGER_BASE',
90
- description: 'A branch/tag/commit to use as the base of the diff. [master|dev|stable]',
91
- type: String,
92
- optional: true),
93
- PantographCore::ConfigItem.new(key: :head,
94
- env_name: 'DANGER_HEAD',
95
- description: 'A branch/tag/commit to use as the head. [master|dev|stable]',
96
- type: String,
97
- optional: true),
98
- PantographCore::ConfigItem.new(key: :pr,
99
- env_name: 'DANGER_PR',
100
- description: 'Run danger on a specific pull request. e.g. \"https://github.com/danger/danger/pull/518\"',
101
- type: String,
102
- optional: true)
42
+ PantographCore::ConfigItem.new(
43
+ key: :use_bundle_exec,
44
+ env_name: 'DANGER_USE_BUNDLE_EXEC',
45
+ description: 'Use bundle exec when there is a Gemfile presented',
46
+ is_string: false,
47
+ default_value: true
48
+ ),
49
+ PantographCore::ConfigItem.new(
50
+ key: :verbose,
51
+ env_name: 'DANGER_VERBOSE',
52
+ description: 'Show more debugging information',
53
+ is_string: false,
54
+ default_value: false
55
+ ),
56
+ PantographCore::ConfigItem.new(
57
+ key: :danger_id,
58
+ env_name: 'DANGER_ID',
59
+ description: 'The identifier of this Danger instance',
60
+ type: String,
61
+ optional: true
62
+ ),
63
+ PantographCore::ConfigItem.new(
64
+ key: :dangerfile,
65
+ env_name: 'DANGER_DANGERFILE',
66
+ description: 'The location of your Dangerfile',
67
+ type: String,
68
+ optional: false,
69
+ default_value: 'Dangerfile'
70
+ ),
71
+ PantographCore::ConfigItem.new(
72
+ key: :github_api_token,
73
+ env_name: 'DANGER_GITHUB_API_TOKEN',
74
+ description: 'GitHub API token for danger',
75
+ sensitive: true,
76
+ type: String,
77
+ optional: true
78
+ ),
79
+ PantographCore::ConfigItem.new(
80
+ key: :fail_on_errors,
81
+ env_name: 'DANGER_FAIL_ON_ERRORS',
82
+ description: 'Should always fail the build process, defaults to false',
83
+ is_string: false,
84
+ optional: true,
85
+ default_value: false
86
+ ),
87
+ PantographCore::ConfigItem.new(
88
+ key: :new_comment,
89
+ env_name: 'DANGER_NEW_COMMENT',
90
+ description: 'Makes Danger post a new comment instead of editing its previous one',
91
+ is_string: false,
92
+ optional: true,
93
+ default_value: false
94
+ ),
95
+ PantographCore::ConfigItem.new(
96
+ key: :remove_previous_comments,
97
+ env_name: 'DANGER_REMOVE_PREVIOUS_COMMENT',
98
+ description: 'Makes Danger remove all previous comment and create a new one in the end of the list',
99
+ is_string: false,
100
+ optional: true,
101
+ default_value: false
102
+ ),
103
+ PantographCore::ConfigItem.new(
104
+ key: :base,
105
+ env_name: 'DANGER_BASE',
106
+ description: 'A branch/tag/commit to use as the base of the diff. [master|dev|stable]',
107
+ type: String,
108
+ optional: true
109
+ ),
110
+ PantographCore::ConfigItem.new(
111
+ key: :head,
112
+ env_name: 'DANGER_HEAD',
113
+ description: 'A branch/tag/commit to use as the head. [master|dev|stable]',
114
+ type: String,
115
+ optional: true
116
+ ),
117
+ PantographCore::ConfigItem.new(
118
+ key: :pr,
119
+ env_name: 'DANGER_PR',
120
+ description: 'Run danger on a specific pull request. e.g. \"https://github.com/danger/danger/pull/518\"',
121
+ type: String,
122
+ optional: true
123
+ )
103
124
  ]
104
125
  end
105
126
 
@@ -120,11 +141,11 @@ module Pantograph
120
141
  end
121
142
 
122
143
  def self.category
123
- :misc
144
+ :source_control
124
145
  end
125
146
 
126
147
  def self.authors
127
- ['KrauseFx']
148
+ ['KrauseFx', 'johnknapprs']
128
149
  end
129
150
  end
130
151
  end
@@ -7,7 +7,7 @@ module Pantograph
7
7
  end
8
8
 
9
9
  def self.description
10
- "Print out an overview of the lane context values"
10
+ 'Print out an overview of the lane context values'
11
11
  end
12
12
 
13
13
  def self.is_supported?(platform)
@@ -25,7 +25,7 @@ module Pantograph
25
25
  end
26
26
 
27
27
  def self.author
28
- "KrauseFx"
28
+ 'KrauseFx'
29
29
  end
30
30
  end
31
31
  end
@@ -6,7 +6,9 @@ module Pantograph
6
6
 
7
7
  class DefaultPlatformAction < Action
8
8
  def self.run(params)
9
- UI.user_error!("You forgot to pass the default platform") if params.first.nil?
9
+ if params.first.nil?
10
+ UI.user_error!('You forgot to pass the default platform')
11
+ end
10
12
 
11
13
  platform = params.first.to_sym
12
14
 
@@ -16,7 +18,7 @@ module Pantograph
16
18
  end
17
19
 
18
20
  def self.description
19
- "Defines a default platform to not have to specify the platform"
21
+ 'Defines a default platform to not have to specify the platform'
20
22
  end
21
23
 
22
24
  def self.output
@@ -36,7 +38,7 @@ module Pantograph
36
38
  end
37
39
 
38
40
  def self.author
39
- "KrauseFx"
41
+ 'KrauseFx'
40
42
  end
41
43
 
42
44
  def self.is_supported?(platform)
@@ -31,20 +31,21 @@ module Pantograph
31
31
 
32
32
  def self.details
33
33
  [
34
- "Specify the URL to download and get the content as a return value.",
35
- "Automatically parses JSON into a Ruby data structure.",
36
- "For more advanced networking code, use the Ruby functions instead: [http://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html](http://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html)."
34
+ 'Specify the URL to download and get the content as a return value.',
35
+ 'Automatically parses JSON into a Ruby data structure.'
37
36
  ].join("\n")
38
37
  end
39
38
 
40
39
  def self.available_options
41
40
  [
42
- PantographCore::ConfigItem.new(key: :url,
43
- env_name: 'DOWNLOAD_URL',
44
- description: "The URL that should be downloaded",
45
- verify_block: proc do |value|
46
- UI.important("The URL doesn't start with http or https") unless value.start_with?("http")
47
- end)
41
+ PantographCore::ConfigItem.new(
42
+ key: :url,
43
+ env_name: 'DOWNLOAD_URL',
44
+ description: 'The URL that should be downloaded',
45
+ verify_block: proc do |value|
46
+ UI.important('The URL does not start with http or https') unless value.start_with?('http')
47
+ end
48
+ )
48
49
  ]
49
50
  end
50
51
 
@@ -7,7 +7,7 @@ module Pantograph
7
7
  #####################################################
8
8
 
9
9
  def self.description
10
- "Alias for the `puts` action"
10
+ 'Alias for the `puts` action'
11
11
  end
12
12
  end
13
13
  end
@@ -1,16 +1,20 @@
1
1
  module Pantograph
2
2
  module Actions
3
- module SharedValues
4
- end
5
-
6
3
  # Raises an exception and stop the lane execution if not using bundle exec to run pantograph
7
4
  class EnsureBundleExecAction < Action
8
5
  def self.run(params)
9
6
  return if PluginManager.new.gemfile_path.nil?
10
7
  if PantographCore::Helper.bundler?
11
- UI.success("Using bundled pantograph ✅")
8
+ UI.success('Using bundled pantograph ✅')
12
9
  else
13
- UI.user_error!("pantograph detected a Gemfile in the current directory. However it seems like you don't use `bundle exec`. Use `bundle exec pantograph #{ARGV.join(' ')}`")
10
+ error_message = [
11
+ 'pantograph detected a Gemfile in the current directory.',
12
+ 'However it seems like you did not use `bundle exec`.',
13
+ "Use `bundle exec pantograph #{ARGV.join(' ')}`"
14
+ ]
15
+ error_message = error_message.join(' ')
16
+
17
+ UI.user_error!(error_message)
14
18
  end
15
19
  end
16
20
 
@@ -19,13 +23,12 @@ module Pantograph
19
23
  #####################################################
20
24
 
21
25
  def self.description
22
- "Raises an exception if not using `bundle exec` to run pantograph"
26
+ 'Raises an exception if not using `bundle exec` to run pantograph'
23
27
  end
24
28
 
25
29
  def self.details
26
30
  [
27
- "This action will check if you are using bundle exec to run pantograph.",
28
- "You can put it into `before_all` and make sure that pantograph is run using `bundle exec pantograph` command."
31
+ 'This action will check if you are using bundle exec to run pantograph.'
29
32
  ].join("\n")
30
33
  end
31
34
 
@@ -38,12 +41,17 @@ module Pantograph
38
41
  end
39
42
 
40
43
  def self.author
41
- ['rishabhtayal']
44
+ ['rishabhtayal', 'johnknapprs']
42
45
  end
43
46
 
44
47
  def self.example_code
45
48
  [
46
- "ensure_bundle_exec"
49
+ 'ensure_bundle_exec',
50
+ ' # always check before running a lane
51
+ before_all do
52
+ ensure_bundle_exec
53
+ end
54
+ '
47
55
  ]
48
56
  end
49
57
 
@@ -2,17 +2,15 @@ module Pantograph
2
2
  module Actions
3
3
  class EnsureEnvVarsAction < Action
4
4
  def self.run(params)
5
- variables = params[:env_vars]
6
-
7
- variables.each do |variable|
8
- next unless ENV[variable].to_s.strip.empty?
9
-
10
- UI.user_error!("Missing environment variable '#{variable}'")
5
+ null_keys = params[:vars].reject do |var|
6
+ ENV.key?(var)
11
7
  end
12
8
 
13
- is_one = variables.length == 1
9
+ if null_keys.any?
10
+ UI.user_error!("Unable to find ENV Variable(s):\n#{null_keys.join("\n")}")
11
+ end
14
12
 
15
- UI.success("Environment variable#{is_one ? '' : 's'} '#{variables.join('\', \'')}' #{is_one ? 'is' : 'are'} set!")
13
+ UI.success("ENV variable(s) '#{params[:vars].join('\', \'')}' set!")
16
14
  end
17
15
 
18
16
  def self.description
@@ -20,28 +18,29 @@ module Pantograph
20
18
  end
21
19
 
22
20
  def self.details
23
- 'This action will check if some environment variables are set.'
24
21
  end
25
22
 
26
23
  def self.available_options
27
24
  [
28
- PantographCore::ConfigItem.new(key: :env_vars,
29
- description: 'The environment variables names that should be checked',
30
- type: Array,
31
- verify_block: proc do |value|
32
- UI.user_error!('Specify at least one environment variable name') if value.empty?
33
- end)
25
+ PantographCore::ConfigItem.new(
26
+ key: :vars,
27
+ description: 'The ENV variables keys to verify',
28
+ type: Array,
29
+ verify_block: proc do |value|
30
+ UI.user_error!('Specify at least one environment variable key') if value.empty?
31
+ end
32
+ )
34
33
  ]
35
34
  end
36
35
 
37
36
  def self.authors
38
- ['revolter']
37
+ ['johnknapprs']
39
38
  end
40
39
 
41
40
  def self.example_code
42
41
  [
43
42
  'ensure_env_vars(
44
- env_vars: [\'GITHUB_USER_NAME\', \'GITHUB_API_TOKEN\']
43
+ vars: [\'GITHUB_USER_NAME\', \'GITHUB_API_TOKEN\']
45
44
  )'
46
45
  ]
47
46
  end
@@ -1,17 +1,15 @@
1
1
  module Pantograph
2
2
  module Actions
3
- module SharedValues
4
- end
5
-
6
3
  # Raises an exception and stop the lane execution if the repo is not on a specific branch
7
4
  class EnsureGitBranchAction < Action
8
5
  def self.run(params)
9
- branch = params[:branch]
10
- branch_expr = /#{branch}/
11
- if Actions.git_branch =~ branch_expr
12
- UI.success("Git branch matches `#{branch}`, all good! 💪")
6
+ target_branch = params[:branch]
7
+ current_branch = Helper::Git.current_branch
8
+
9
+ if current_branch =~ /#{target_branch}/
10
+ UI.success("Git branch matches `#{target_branch}`, all good! 💪")
13
11
  else
14
- UI.user_error!("Git is not on a branch matching `#{branch}`. Current branch is `#{Actions.git_branch}`! Please ensure the repo is checked out to the correct branch.")
12
+ UI.user_error!("Git is not on a branch matching `#{target_branch}`. Current branch is `#{current_branch}`!")
15
13
  end
16
14
  end
17
15
 
@@ -32,11 +30,13 @@ module Pantograph
32
30
 
33
31
  def self.available_options
34
32
  [
35
- PantographCore::ConfigItem.new(key: :branch,
36
- env_name: 'ENSURE_GIT_BRANCH_NAME',
37
- description: "The branch that should be checked for. String that can be either the full name of the branch or a regex to match",
38
- type: String,
39
- default_value: 'master')
33
+ PantographCore::ConfigItem.new(
34
+ key: :branch,
35
+ env_name: 'ENSURE_GIT_BRANCH_NAME',
36
+ description: 'The branch that should be checked for. String that can be either the full name of the branch or a regex to match',
37
+ type: String,
38
+ default_value: 'master'
39
+ )
40
40
  ]
41
41
  end
42
42
 
@@ -45,7 +45,7 @@ module Pantograph
45
45
  end
46
46
 
47
47
  def self.author
48
- ['dbachrach', 'Liquidsoul']
48
+ ['dbachrach', 'Liquidsoul', 'johnknapprs']
49
49
  end
50
50
 
51
51
  def self.example_code
@@ -1,72 +1,56 @@
1
1
  module Pantograph
2
2
  module Actions
3
3
  module SharedValues
4
- GIT_REPO_WAS_CLEAN_ON_START = :GIT_REPO_WAS_CLEAN_ON_START
4
+ ENSURE_GIT_STATUS_CLEAN = :ENSURE_GIT_STATUS_CLEAN
5
5
  end
6
6
 
7
7
  # Raises an exception and stop the lane execution if the repo is not in a clean state
8
8
  class EnsureGitStatusCleanAction < Action
9
9
  def self.run(params)
10
- repo_status = Actions.sh("git status --porcelain")
11
- repo_clean = repo_status.empty?
10
+ repo_status = Helper::Git.repo_status
12
11
 
13
- if repo_clean
12
+ if repo_status.empty?
14
13
  UI.success('Git status is clean, all good! 💪')
15
- Actions.lane_context[SharedValues::GIT_REPO_WAS_CLEAN_ON_START] = true
14
+ Actions.lane_context[SharedValues::ENSURE_GIT_STATUS_CLEAN] = true
16
15
  else
17
- error_message = 'Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.'
18
- error_message += "\nUncommitted changes:\n#{repo_status}" if params[:show_uncommitted_changes]
19
- if params[:show_diff]
20
- repo_diff = Actions.sh("git diff")
21
- error_message += "\nGit diff: \n#{repo_diff}"
22
- end
16
+ error_message = [
17
+ 'Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.',
18
+ 'Uncommitted changes:',
19
+ repo_status
20
+ ].join("\n")
21
+
23
22
  UI.user_error!(error_message)
24
23
  end
25
24
  end
26
25
 
27
26
  def self.description
28
- 'Raises an exception if there are uncommitted git changes'
27
+ 'Raises error if there are uncommitted git changes'
29
28
  end
30
29
 
31
30
  def self.details
32
- [
33
- 'A sanity check to make sure you are working in a repo that is clean.',
34
- 'Especially useful to put at the beginning of your Pantfile in the `before_all` block, if some of your other actions will touch your filesystem, do things to your git repo, or just as a general reminder to save your work.',
35
- 'Also needed as a prerequisite for some other actions like `reset_git_repo`.'
36
- ].join("\n")
37
31
  end
38
32
 
39
33
  def self.output
40
34
  [
41
- ['GIT_REPO_WAS_CLEAN_ON_START', 'Stores the fact that the git repo was clean at some point']
35
+ ['ENSURE_GIT_STATUS_CLEAN', 'Returns `true` if status clean when executed']
42
36
  ]
43
37
  end
44
38
 
45
39
  def self.author
46
- ['lmirosevic', 'antondomashnev']
40
+ ['lmirosevic', 'antondomashnev', 'johnknapprs']
47
41
  end
48
42
 
49
43
  def self.example_code
50
44
  [
51
- 'ensure_git_status_clean'
45
+ 'before_all do
46
+ # Prevent pantograph from running lanes when git is in a dirty state
47
+ ensure_git_status_clean
48
+ end'
52
49
  ]
53
50
  end
54
51
 
55
52
  def self.available_options
56
- [
57
- PantographCore::ConfigItem.new(key: :show_uncommitted_changes,
58
- env_name: 'ENSURE_GIT_STATUS_CLEAN_SHOW_UNCOMMITTED_CHANGES',
59
- description: 'The flag whether to show uncommitted changes if the repo is dirty',
60
- optional: true,
61
- default_value: false,
62
- is_string: false),
63
- PantographCore::ConfigItem.new(key: :show_diff,
64
- env_name: 'ENSURE_GIT_STATUS_CLEAN_SHOW_DIFF',
65
- description: 'The flag whether to show the git diff if the repo is dirty',
66
- optional: true,
67
- default_value: false,
68
- is_string: false)
69
- ]
53
+ []
70
54
  end
71
55
 
72
56
  def self.category
@@ -144,7 +144,7 @@ module Pantograph
144
144
 
145
145
  def self.example_code
146
146
  [
147
- 'release = get_github_release(url: "pantograph/pantograph", version: "1.0.0")
147
+ 'release = get_github_release(url: "johnknapprs/pantograph", version: "1.0.0")
148
148
  puts release["name"]'
149
149
  ]
150
150
  end
@@ -1,13 +1,12 @@
1
1
  module Pantograph
2
2
  module Actions
3
3
  module SharedValues
4
- GIT_BRANCH_ENV_VARS = %w(GIT_BRANCH BRANCH_NAME TRAVIS_BRANCH BITRISE_GIT_BRANCH CI_BUILD_REF_NAME CI_COMMIT_REF_NAME WERCKER_GIT_BRANCH BUILDKITE_BRANCH).freeze
4
+ GIT_BRANCH_NAME = :GIT_BRANCH_NAME
5
5
  end
6
6
 
7
7
  class GitBranchAction < Action
8
8
  def self.run(params)
9
- env_name = SharedValues::GIT_BRANCH_ENV_VARS.find { |env_var| PantographCore::Env.truthy?(env_var) }
10
- ENV.fetch(env_name.to_s) { `git symbolic-ref HEAD --short 2>/dev/null`.strip }
9
+ Actions.lane_context[SharedValues::GIT_BRANCH_NAME] = Helper::Git.current_branch
11
10
  end
12
11
 
13
12
  #####################################################
@@ -15,11 +14,11 @@ module Pantograph
15
14
  #####################################################
16
15
 
17
16
  def self.description
18
- "Returns the name of the current git branch, possibly as managed by CI ENV vars"
17
+ 'Returns the name of the current git branch'
19
18
  end
20
19
 
21
20
  def self.details
22
- "If no branch could be found, this action will return an empty string"
21
+ 'If no branch could be found, this action will return an empty string'
23
22
  end
24
23
 
25
24
  def self.available_options
@@ -28,12 +27,12 @@ module Pantograph
28
27
 
29
28
  def self.output
30
29
  [
31
- ['GIT_BRANCH_ENV_VARS', 'The git branch environment variables']
30
+ ['GIT_BRANCH_NAME', 'The git branch name']
32
31
  ]
33
32
  end
34
33
 
35
34
  def self.authors
36
- ["KrauseFx"]
35
+ ['johnknapprs']
37
36
  end
38
37
 
39
38
  def self.is_supported?(platform)