diff --git a/xcode/build_phases/multiple_swiftlint/setting_option.rb b/xcode/build_phases/multiple_swiftlint/setting_option.rb index 923acab..998cd83 100644 --- a/xcode/build_phases/multiple_swiftlint/setting_option.rb +++ b/xcode/build_phases/multiple_swiftlint/setting_option.rb @@ -9,11 +9,11 @@ class SettingOption OptionParser.new do |opt| opt.on('-s', '--source_directory STRING', 'The directory of source') { |option| @options.source_directory = option } opt.on('-l', '--swiftlint_executable_path STRING', 'The executable path of swiftlint') { |option| @options.swiftlint_executable_path = option } + opt.on('-g', '--git_directory STRING', 'The directory of git') { |option| @options.git_directory = option } opt.on('-c', '--check_mode MODE', 'The mode of check is "fully" or "simplified"') { |option| @options.check_mode = option } opt.on('-u', '--use_multiple BOOL', 'The flag indicates the use of multiple yaml swiftlint configurations') { |option| @options.use_multiple = option } opt.on('-d', '--source_date DATE', 'The date of grouping files according touchin and old swiftlint rules') { |option| @options.source_date = option } opt.on('-y', '--touchin_swiftlint_yaml_path STRING', 'The path to the touchin swiftlint yaml relative to the source directory') { |option| @options.touchin_swiftlint_yaml_path = option } - opt.on('-g', '--depth_git_count Int', 'The depth between the git directory and sources directory') { |option| @options.depth_git_count = option } end.parse! if @options.check_mode.to_s.nilOrEmpty? @@ -24,8 +24,8 @@ class SettingOption @options.use_multiple = 'false' end - if @options.depth_git_count.to_s.nilOrEmpty? - @options.depth_git_count = 0 + if @options.git_directory.to_s.nilOrEmpty? + @options.git_directory = @options.source_directory end if @options.touchin_swiftlint_yaml_path.to_s.nilOrEmpty? @@ -53,8 +53,8 @@ class SettingOption @options.use_multiple end - def depth_git_count - @options.depth_git_count + def git_directory + @options.git_directory end def touchin_swiftlint_yaml_path diff --git a/xcode/build_phases/multiple_swiftlint/strategy_maker.rb b/xcode/build_phases/multiple_swiftlint/strategy_maker.rb index 28e4ee3..e92c0bb 100644 --- a/xcode/build_phases/multiple_swiftlint/strategy_maker.rb +++ b/xcode/build_phases/multiple_swiftlint/strategy_maker.rb @@ -37,7 +37,7 @@ class StrategyMaker run_multiple_strategy(@touchin_swiftlint_yaml_temporary_path, @old_swiftlint_yaml_temporary_path) end - def run_simplified_multiple_strategy(source_date, depth_git_count) + def run_simplified_multiple_strategy(source_date, git_directory) included_files = GitСaretaker.get_modified_files if included_files.nilOrEmpty? @@ -48,7 +48,7 @@ class StrategyMaker create_yaml_managers_and_copy_temporary_files exclude_files = unique_exclude_files(@touchin_swiftlint_yaml_manager, @old_swiftlint_yaml_manager) - included_files = included_files.map { |file_path| file_path.add_back_to_path(depth_git_count) } + included_files = included_files.map { |file_path| git_directory + file_path } swift_file_manager = SwiftFileManager.new(exclude_files, source_date) swift_file_manager.find_list_file_paths_from(included_files) @@ -80,7 +80,7 @@ class StrategyMaker run_single_strategy(@touchin_swiftlint_yaml_path) end - def run_simplified_single_strategy(depth_git_count) + def run_simplified_single_strategy(git_directory) included_files = GitСaretaker.get_modified_files if included_files.nilOrEmpty? @@ -95,7 +95,7 @@ class StrategyMaker swift_files = SwiftFileManager.new(touchin_excluded_files, '') included_files = included_files.select { |file_name| not swift_files.is_excluded_file(file_name) } - included_files = included_files.map { |file_path| file_path.add_back_to_path(depth_git_count) } + included_files = included_files.map { |file_path| git_directory + file_path } touchin_swiftlint_yaml_manager.update('excluded', []) touchin_swiftlint_yaml_manager.update('included', included_files) diff --git a/xcode/build_phases/multiple_swiftlint/string_extension.rb b/xcode/build_phases/multiple_swiftlint/string_extension.rb index 5b409e1..33a6357 100644 --- a/xcode/build_phases/multiple_swiftlint/string_extension.rb +++ b/xcode/build_phases/multiple_swiftlint/string_extension.rb @@ -11,14 +11,6 @@ class String self.to_s.downcase == "true" end - def add_back_to_path(count) - string = self - count.to_i.times { |i| - string = '../' + string - } - return string - end - def nilOrEmpty? self.nil? or self.empty? end diff --git a/xcode/build_phases/multiple_swiftlint/swiftlint.rb b/xcode/build_phases/multiple_swiftlint/swiftlint.rb index 533c927..74d1f6c 100644 --- a/xcode/build_phases/multiple_swiftlint/swiftlint.rb +++ b/xcode/build_phases/multiple_swiftlint/swiftlint.rb @@ -13,7 +13,7 @@ if setting.check_mode.eql? 'fully' and setting.use_multiple.true? elsif setting.check_mode.eql? 'fully' and not setting.use_multiple.true? strategy_maker.run_fully_single_strategy elsif setting.check_mode.eql? 'simplified' and setting.use_multiple.true? - strategy_maker.run_simplified_multiple_strategy(setting.source_date, setting.depth_git_count) + strategy_maker.run_simplified_multiple_strategy(setting.source_date, setting.git_directory) elsif setting.check_mode.eql? 'simplified' and not setting.use_multiple.true? - strategy_maker.run_simplified_single_strategy(setting.depth_git_count) + strategy_maker.run_simplified_single_strategy(setting.git_directory) end