From 5504f8ee9065a89ba437dd9bd6385814f2bfc700 Mon Sep 17 00:00:00 2001 From: Manish Rathi Date: Sun, 13 Jun 2021 16:46:29 +0200 Subject: [PATCH 1/4] [action][git_commit] remove all instances of `is_string` in options and use `type` --- fastlane/lib/fastlane/actions/git_commit.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fastlane/lib/fastlane/actions/git_commit.rb b/fastlane/lib/fastlane/actions/git_commit.rb index 41474ae2bea..874fa0d6437 100644 --- a/fastlane/lib/fastlane/actions/git_commit.rb +++ b/fastlane/lib/fastlane/actions/git_commit.rb @@ -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' : '' @@ -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, From 805dbe769b87f2e9bf8d321ddb318d757d5a175e Mon Sep 17 00:00:00 2001 From: Manish Rathi Date: Sun, 13 Jun 2021 17:06:28 +0200 Subject: [PATCH 2/4] Making `test_sample_code` happy --- fastlane/lib/fastlane/actions/git_commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/lib/fastlane/actions/git_commit.rb b/fastlane/lib/fastlane/actions/git_commit.rb index 874fa0d6437..ebf7c987d15 100644 --- a/fastlane/lib/fastlane/actions/git_commit.rb +++ b/fastlane/lib/fastlane/actions/git_commit.rb @@ -67,7 +67,7 @@ def self.is_supported?(platform) def self.example_code [ - 'git_commit(path: "./version.txt", message: "Version Bump")', + #'git_commit(path: "./version.txt", message: "Version Bump")', 'git_commit(path: ["./version.txt", "./changelog.txt"], message: "Version Bump")', 'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation")', 'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation", skip_git_hooks: true)' From 30436d5932979a39fddfc07b46649c455e0c7e52 Mon Sep 17 00:00:00 2001 From: Manish Rathi Date: Sun, 13 Jun 2021 17:14:14 +0200 Subject: [PATCH 3/4] Happy linting --- fastlane/lib/fastlane/actions/git_commit.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/lib/fastlane/actions/git_commit.rb b/fastlane/lib/fastlane/actions/git_commit.rb index ebf7c987d15..94feb5e9203 100644 --- a/fastlane/lib/fastlane/actions/git_commit.rb +++ b/fastlane/lib/fastlane/actions/git_commit.rb @@ -67,7 +67,7 @@ def self.is_supported?(platform) def self.example_code [ - #'git_commit(path: "./version.txt", message: "Version Bump")', + # 'git_commit(path: "./version.txt", message: "Version Bump")', 'git_commit(path: ["./version.txt", "./changelog.txt"], message: "Version Bump")', 'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation")', 'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation", skip_git_hooks: true)' From a59777c7ec53bf3a5e99b5641bb66511118c72d3 Mon Sep 17 00:00:00 2001 From: Josh Holtz Date: Tue, 15 Jun 2021 14:03:08 -0500 Subject: [PATCH 4/4] Fix for test_sample_code when string passed to array type --- fastlane/actions/test_sample_code.rb | 2 ++ fastlane/lib/fastlane/actions/git_commit.rb | 2 +- .../lib/fastlane_core/configuration/config_item.rb | 13 +++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/fastlane/actions/test_sample_code.rb b/fastlane/actions/test_sample_code.rb index 44439da4676..449ba3bb6f9 100644 --- a/fastlane/actions/test_sample_code.rb +++ b/fastlane/actions/test_sample_code.rb @@ -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 diff --git a/fastlane/lib/fastlane/actions/git_commit.rb b/fastlane/lib/fastlane/actions/git_commit.rb index 94feb5e9203..874fa0d6437 100644 --- a/fastlane/lib/fastlane/actions/git_commit.rb +++ b/fastlane/lib/fastlane/actions/git_commit.rb @@ -67,7 +67,7 @@ def self.is_supported?(platform) def self.example_code [ - # 'git_commit(path: "./version.txt", message: "Version Bump")', + 'git_commit(path: "./version.txt", message: "Version Bump")', 'git_commit(path: ["./version.txt", "./changelog.txt"], message: "Version Bump")', 'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation")', 'git_commit(path: ["./*.txt", "./*.md"], message: "Update documentation", skip_git_hooks: true)' diff --git a/fastlane_core/lib/fastlane_core/configuration/config_item.rb b/fastlane_core/lib/fastlane_core/configuration/config_item.rb index 4c1fd0c6b42..12fece218a7 100644 --- a/fastlane_core/lib/fastlane_core/configuration/config_item.rb +++ b/fastlane_core/lib/fastlane_core/configuration/config_item.rb @@ -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) @@ -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