diff --git a/src/rules/git_pull.rs b/src/rules/git_pull.rs index 215c069..24ede3f 100644 --- a/src/rules/git_pull.rs +++ b/src/rules/git_pull.rs @@ -1,9 +1,12 @@ use crate::{ - cli::command::CrabCommand, rules::utils::git::match_rule_with_git_support, shell::Shell, + cli::command::CrabCommand, + rules::{ + utils::git::{get_new_command_with_git_support, match_rule_with_git_support}, + Rule, + }, + shell::Shell, }; -use super::{utils::git::get_new_command_with_git_support, Rule}; - fn auxiliary_match_rule(command: &CrabCommand) -> bool { if let Some(stdout) = &command.output { command.script.contains("pull") && stdout.contains("set-upstream") diff --git a/src/rules/git_tag_force.rs b/src/rules/git_tag_force.rs index 4c1fd81..1a54f65 100644 --- a/src/rules/git_tag_force.rs +++ b/src/rules/git_tag_force.rs @@ -1,35 +1,34 @@ use crate::{ cli::command::CrabCommand, - rules::{match_rule_with_git_support, utils::git::get_new_command_with_git_support}, - Rule, + rules::{ + utils::git::{get_new_command_with_git_support, match_rule_with_git_support}, + Rule, + }, + shell::Shell, }; -use shell::Shell; fn auxiliary_match_rule(command: &CrabCommand) -> bool { - command.script.split_whitespace().any(|part| part == "tag") - && command - .output - .as_ref() - .map_or(false, |o| o.contains("already exists")) + if let Some(output) = &command.output { + command.script_parts.contains(&"tag".to_string()) && output.contains("already exists") + } else { + false + } } -pub fn match_rule(command: &mut CrabCommand, _system_shell: Option<&dyn Shell>) -> bool { +pub fn match_rule(command: &mut CrabCommand, system_shell: Option<&dyn Shell>) -> bool { match_rule_with_git_support(auxiliary_match_rule, command) } fn auxiliary_get_new_command( command: &CrabCommand, - _system_shell: Option<&dyn Shell>, + system_shell: Option<&dyn Shell>, ) -> Vec { let new_script = command.script.replacen("tag", "tag --force", 1); vec![new_script] } -pub fn get_new_command( - command: &mut CrabCommand, - _system_shell: Option<&dyn Shell>, -) -> Vec { - get_new_command_with_git_support(auxiliary_get_new_command, command, _system_shell) +pub fn get_new_command(command: &mut CrabCommand, system_shell: Option<&dyn Shell>) -> Vec { + get_new_command_with_git_support(auxiliary_get_new_command, command, system_shell) } pub fn get_rule() -> Rule { diff --git a/src/rules/mod.rs b/src/rules/mod.rs index 78fcb37..bf03d33 100644 --- a/src/rules/mod.rs +++ b/src/rules/mod.rs @@ -70,13 +70,13 @@ mod git_push_without_commits; mod git_rebase_merge_dir; mod git_rebase_no_changes; mod git_remote_delete; -mod git_tag_force; mod git_remote_seturl_add; mod git_rm_local_modifications; mod git_rm_recursive; mod git_rm_staged; mod git_stash; mod git_stash_pop; +mod git_tag_force; mod git_two_dashes; mod go_run; mod gradle_wrapper;