|
1 | 1 | #![expect(clippy::unwrap_used, reason = "contains legacy code which uses unwrap")] |
2 | 2 |
|
| 3 | +use std::sync::LazyLock; |
| 4 | + |
3 | 5 | use anyhow::{bail, Result}; |
4 | 6 | use clap::{Arg, ArgAction, ArgMatches, Command}; |
5 | 7 | use lazy_static::lazy_static; |
@@ -82,7 +84,8 @@ fn strip_sha(sha: &str) -> &str { |
82 | 84 |
|
83 | 85 | /// Validates that a string is a valid Git SHA (full or partial) |
84 | 86 | 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")); |
86 | 89 | SHA_RE.is_match(sha) |
87 | 90 | } |
88 | 91 |
|
@@ -120,15 +123,15 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { |
120 | 123 | } |
121 | 124 |
|
122 | 125 | 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.", |
125 | 128 | commit_spec.rev |
126 | 129 | ); |
127 | 130 | } |
128 | 131 |
|
129 | 132 | if let Some(ref prev_rev) = commit_spec.prev_rev { |
130 | 133 | 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."); |
132 | 135 | } |
133 | 136 | } |
134 | 137 |
|
|
0 commit comments