Skip to content

Commit

Permalink
[action][git_commit] remove all instances of is_string in options a…
Browse files Browse the repository at this point in the history
…nd use `type` (#18883)

* [action][git_commit] remove all instances of `is_string` in options and use `type`

* Making `test_sample_code` happy

* Happy linting

* Fix for test_sample_code when string passed to array type

Co-authored-by: Josh Holtz <josh@rokkincat.com>
  • Loading branch information
crazymanish and Josh Holtz committed Jun 15, 2021
1 parent cfaf369 commit ec7625e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions fastlane/actions/test_sample_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def self.method_missing(method_sym, *arguments, &_block)

if config_item.data_type == Fastlane::Boolean
config_item.ensure_boolean_type_passes_validation(value)
elsif config_item.data_type == Array
config_item.ensure_array_type_passes_validation(value)
else
config_item.ensure_generic_type_passes_validation(value)
end
Expand Down
8 changes: 2 additions & 6 deletions fastlane/lib/fastlane/actions/git_commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ module Fastlane
module Actions
class GitCommitAction < Action
def self.run(params)
if params[:path].kind_of?(String)
paths = params[:path].shellescape
else
paths = params[:path].map(&:shellescape).join(' ')
end
paths = params[:path].map(&:shellescape).join(' ')

skip_git_hooks = params[:skip_git_hooks] ? '--no-verify' : ''

Expand Down Expand Up @@ -38,7 +34,7 @@ def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
description: "The file(s) or directory(ies) you want to commit. You can pass an array of multiple file-paths or fileglobs \"*.txt\" to commit all matching files. The files already staged but not specified and untracked files won't be committed",
is_string: false),
type: Array),
FastlaneCore::ConfigItem.new(key: :message,
description: "The commit message that should be used"),
FastlaneCore::ConfigItem.new(key: :skip_git_hooks,
Expand Down
13 changes: 13 additions & 0 deletions fastlane_core/lib/fastlane_core/configuration/config_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,17 @@ def ensure_boolean_type_passes_validation(value)
end
end

def ensure_array_type_passes_validation(value)
if @skip_type_validation
return
end

# Arrays can be an either be an array or string that gets split by comma in auto_convert_type
if !value.kind_of?(Array) && !value.kind_of?(String)
UI.user_error!("'#{self.key}' value must be either `true` or `false`! Found #{value.class} instead.")
end
end

# Make sure, the value is valid (based on the verify block)
# Raises an exception if the value is invalid
def valid?(value)
Expand All @@ -225,6 +236,8 @@ def valid?(value)
# Verify that value is the type that we're expecting, if we are expecting a type
if data_type == Fastlane::Boolean
ensure_boolean_type_passes_validation(value)
elsif data_type == Array
ensure_array_type_passes_validation(value)
else
ensure_generic_type_passes_validation(value)
end
Expand Down

0 comments on commit ec7625e

Please sign in to comment.