Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action][git_commit] remove all instances of is_string in options and use type #18883

Merged
merged 4 commits into from Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions fastlane/actions/test_sample_code.rb
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
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
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.")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UI.user_error!("'#{self.key}' value must be either `true` or `false`! Found #{value.class} instead.")
UI.user_error!("'#{self.key}' value must be either `array` or `comma seperated string`! 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