Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: 0xPolygon/cdk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 15abd58341335f70bec686d5ac3c9442ef7e2ead
Choose a base ref
..
head repository: 0xPolygon/cdk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1413a01ef560928b83e03a37cd72c6ba6ba9398f
Choose a head ref
Showing with 7 additions and 9 deletions.
  1. +7 −9 crates/cdk/build.rs
16 changes: 7 additions & 9 deletions crates/cdk/build.rs
Original file line number Diff line number Diff line change
@@ -79,14 +79,12 @@ fn build_versions() -> io::Result<()> {
let re_comments = Regex::new(r"#.*$").unwrap(); // Regex to remove comments
let re_trailing_commas = Regex::new(r",(\s*})").unwrap(); // Regex to fix trailing commas

// The versions string is a JSON object we can parse
let versions_json: serde_json::Value = match serde_json::from_str(&versions) {
Ok(json) => json,
Err(e) => {
eprintln!("Failed to parse JSON: {}", e);
return Err(std::io::Error::new(std::io::ErrorKind::Other, "Failed to parse JSON"));
}
};
let cleaned_versions = raw_versions
.lines()
.map(|line| re_comments.replace_all(line, "").trim().to_string()) // Remove comments and trim spaces
.filter(|line| !line.is_empty()) // Filter out empty lines
.collect::<Vec<_>>()
.join("\n");

// Fix improperly placed trailing commas
let cleaned_versions = re_trailing_commas.replace_all(&cleaned_versions, "$1");
@@ -113,4 +111,4 @@ fn build_versions() -> io::Result<()> {
)?;

Ok(())
}
}