Skip to content

Commit 85d334c

Browse files
committed
soft validation
1 parent 9859a9c commit 85d334c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/commands/releases/set_commits.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![expect(clippy::unwrap_used, reason = "contains legacy code which uses unwrap")]
22

3+
use std::sync::LazyLock;
4+
35
use anyhow::{bail, Result};
46
use clap::{Arg, ArgAction, ArgMatches, Command};
57
use lazy_static::lazy_static;
@@ -82,7 +84,8 @@ fn strip_sha(sha: &str) -> &str {
8284

8385
/// Validates that a string is a valid Git SHA (full or partial)
8486
fn is_valid_sha(sha: &str) -> bool {
85-
static SHA_RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"^[a-fA-F0-9]{4,40}$").expect("Regex is valid"));
87+
static SHA_RE: LazyLock<Regex> =
88+
LazyLock::new(|| Regex::new(r"^[a-fA-F0-9]{4,40}$").expect("Regex is valid"));
8689
SHA_RE.is_match(sha)
8790
}
8891

@@ -120,15 +123,15 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
120123
}
121124

122125
if !is_valid_sha(&commit_spec.rev) {
123-
bail!(
124-
"Invalid commit SHA '{}'. Only Git SHAs (full or partial) are supported.",
126+
eprintln!(
127+
"Warning: Invalid commit SHA '{}'. Only Git SHAs (full or partial) are supported. Proceeding anyway.",
125128
commit_spec.rev
126129
);
127130
}
128131

129132
if let Some(ref prev_rev) = commit_spec.prev_rev {
130133
if !is_valid_sha(prev_rev) {
131-
bail!("Invalid previous commit SHA '{}'. Only Git SHAs (full or partial) are supported.", prev_rev);
134+
eprintln!("Warning: Invalid previous commit SHA '{prev_rev}'. Only Git SHAs (full or partial) are supported. Proceeding anyway.");
132135
}
133136
}
134137

0 commit comments

Comments
 (0)