é¡åã®éããgit commit
ã«Hookãã¦ãå¤æ´ããã*.swift
ãã¡ã¤ã«ã«ã®ã¿LintãããããLintã§ã³ã±ããcommitãããªãã¦ä¾¿å©ã
#!/usr/bin/env ruby require 'yaml' LINT_CONFIG_FILE_NAME = '.swiftlint.yml' updated_swiftfiles = `git diff --cached --name-only --diff-filter=AM -- '*.swift'`.split("\n") exit if updated_swiftfiles.empty? lint_config = YAML.load_file(LINT_CONFIG_FILE_NAME) default_included = lint_config['included'] lint_config['included'] = updated_swiftfiles open(LINT_CONFIG_FILE_NAME, 'w') do |file| YAML.dump(lint_config, file) end `swiftlint lint` lint_config['included'] = default_included open(LINT_CONFIG_FILE_NAME, 'w') do |file| YAML.dump(lint_config, file) end
ããããå 容ã "your-repo/.git/hooks/pre-commit" ã«æ¸ãã¦ããã ãã