Skip to content

Commit

Permalink
chore(commit): reinforce skip-ci tests and process
Browse files Browse the repository at this point in the history
  • Loading branch information
ABWassim authored and oknozor committed Mar 8, 2024
1 parent 9bf9045 commit 9f7fcd6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
16 changes: 9 additions & 7 deletions src/bin/cog/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -636,13 +636,15 @@ fn main() -> Result<()> {
cocogitto.run_commit_hook(CommitHook::PreCommit)?;
let commit_message_path = cocogitto.prepare_edit_message_path();

let mut skip_ci_pattern = String::new();

if skip_ci || skip_ci_override.is_some() {
skip_ci_pattern = skip_ci_override.unwrap_or(SETTINGS.skip_ci.clone())
}

let commit_message = message + " " + &skip_ci_pattern;
let commit_message = if skip_ci || skip_ci_override.is_some() {
format!(
"{} {}",
message,
skip_ci_override.unwrap_or(SETTINGS.skip_ci.clone())
)
} else {
message
};

let template = prepare_edit_message(
&typ,
Expand Down
19 changes: 16 additions & 3 deletions tests/cog_tests/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::helpers::*;

use anyhow::Result;
use assert_cmd::prelude::*;
use cmd_lib::run_cmd;
use indoc::{formatdoc, indoc};
use pretty_assertions::assert_eq;
use sealed_test::prelude::*;
Expand Down Expand Up @@ -150,7 +151,10 @@ fn commit_with_default_skip_ci_ok() -> Result<()> {

let commit_message = git_log_head_message()?;

assert!(commit_message.contains("[skip ci]"));
assert_eq!(
commit_message,
"feat(scope): this is a commit message [skip ci]"
);

Ok(())
}
Expand All @@ -175,7 +179,10 @@ fn commit_with_cog_toml_defined_skip_ci_ok() -> Result<()> {

let commit_message = git_log_head_message()?;

assert!(commit_message.contains("[ci-skip]"));
assert_eq!(
commit_message,
"feat(scope): this is a commit message [ci-skip]"
);

Ok(())
}
Expand All @@ -201,7 +208,13 @@ fn commit_with_skip_ci_override_option_takes_precedence() -> Result<()> {

let commit_message = git_log_head_message()?;

assert!(commit_message.contains("[skip-ci-override]"));
assert_eq!(
commit_message,
"feat(scope): this is a commit message [skip-ci-override]"
);

Ok(())
}

#[sealed_test]
fn add_option_git_commit_ok() -> Result<()> {
Expand Down

0 comments on commit 9f7fcd6

Please sign in to comment.