Class: ConventionalCommits::BranchNameCLI
- Inherits:
-
Thor
- Object
- Thor
- ConventionalCommits::BranchNameCLI
- Defined in:
- lib/cli/branch_name_cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #branch(_name) ⇒ Object
- #install_hooks ⇒ Object
- #prepare_commit_msg ⇒ Object
- #validate_branch_name ⇒ Object
- #validate_commit_msg ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
7 8 9 |
# File 'lib/cli/branch_name_cli.rb', line 7 def self.exit_on_failure? true end |
Instance Method Details
#branch(_name) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/cli/branch_name_cli.rb', line 13 def branch(_name) cfg_path = ["cfg_path"] || Configuration::DEFAULT_CONFIGURATION_PATH generator = ConventionalCommits::BranchNameGenerator.new generated_name = generator.generate_name_for(_name.strip, path: cfg_path.strip) Kernel.system("git branch #{generated_name}") rescue StandardError => e raise Thor::Error, e. end |
#install_hooks ⇒ Object
64 65 66 67 68 69 |
# File 'lib/cli/branch_name_cli.rb', line 64 def install_hooks installer = ConventionalCommits::Configuration::HooksInstaller.new installer.install_all rescue StandardError => e raise Thor::Error, e. end |
#prepare_commit_msg ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cli/branch_name_cli.rb', line 26 def prepare_commit_msg source = ["source"] || "" puts source msg_path = ["msg_path"] || Configuration::DEFAULT_COMMIT_MSG_PATH cfg_path = ["cfg_path"] || Configuration::DEFAULT_CONFIGURATION_PATH generator = ConventionalCommits::CommitMessageGenerator.new name = generator.(type: source, cfg_path:, msg_file_path: msg_path) File.write_to_file(msg_path, name) rescue StandardError => e raise Thor::Error, e. end |
#validate_branch_name ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/cli/branch_name_cli.rb', line 41 def validate_branch_name cfg_path = ["cfg_path"] || Configuration::DEFAULT_CONFIGURATION_PATH generator = ConventionalCommits::BranchNameGenerator.new name = ConventionalCommits::Git.new.current_branch_name generator.is_valid_branch(name.strip, path: cfg_path.strip) rescue StandardError => e raise Thor::Error, e. end |
#validate_commit_msg ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/cli/branch_name_cli.rb', line 54 def validate_commit_msg msg_path = ["msg_path"] || Configuration::DEFAULT_COMMIT_MSG_PATH cfg_path = ["cfg_path"] || Configuration::DEFAULT_CONFIGURATION_PATH validator = ConventionalCommits::CommitMessageValidator.new validator.validate_commit_msg_from_file(commit_msg_path: msg_path, cfg_path:) rescue StandardError => e raise Thor::Error, e. end |