Skip to content

Commit 42e27be

Browse files
authored
Fix version capturing regex (#2265)
Closes #2258 I want new `snforge` to work with Scarb `2.6.4` and `2.7.0-rc.0` (planning to release new profiler soon) Disclaimer: no, it doesn't match 0.13.1.1 xD
1 parent 886883d commit 42e27be

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

crates/scarb-api/src/version.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ impl VersionCommand {
3131
}
3232

3333
fn extract_version(version_output: &str, tool: &str) -> Result<Version> {
34-
let version_regex = Regex::new(&format!(r#"(?:{tool}?\s*)([0-9]+.[0-9]+.[0-9]+)"#))
34+
// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
35+
let version_regex = Regex::new(
36+
&format!(r#"{tool}?\s*((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)"#))
3537
.context("Could not create version matching regex")?;
3638

3739
let version_capture = version_regex

snforge_std/src/cheatcodes.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod storage;
1111
mod execution_info;
1212

1313
/// Enum used to specify how long the target should be cheated for.
14-
#[derive(Copy, Drop, Serde, PartialEq, Clone, Debug, Display)]
14+
#[derive(Copy, Drop, Serde, PartialEq, Clone, Debug)]
1515
enum CheatSpan {
1616
/// Applies the cheatcode indefinitely, until the cheat is canceled manually (e.g. using
1717
/// `stop_cheat_block_timestamp`).

0 commit comments

Comments
 (0)