Core diff engine for Scratch SB3 projects. Extracted and refactored from the original scratch-git project.
- Rust library + CLI (
lib+binin one crate). - SB3 as ZIP:
zipcrate. - Text diff:
similar(pure Rust, replaces git diff).
cargo build --features=cli # includes CLI binary
cargo build # library onlycargo test --features=cli# Compare two .sb3 files
scratch-git compare --old old.sb3 --new new.sb3 --format json
# Extract project.json from .sb3
scratch-git extract path.sb3
# Diff two raw text blocks
scratch-git diff-text "old content" "new content"use scratch_git::{compare_sb3, Diff};
// Compare two SB3 files
let commits = compare_sb3("old.sb3", "new.sb3").unwrap();
// Or compare two project.json values
let old = serde_json::from_str(old_json).unwrap();
let new = serde_json::from_str(new_json).unwrap();
let diff = Diff::new(&old);
let commits = diff.commits(&new).unwrap();src/diff.rs— Core diff logic (assets, scripts, commits).src/parse_script.rs— Scratch block JSON to text.src/text_diff.rs— Pure Rust text diff (replaces git::diff).src/zip.rs— SB3 (ZIP) reading.src/sb3.rs— Asset extraction helpers.src/utils.rs— Grouping/intersection utilities.
The simplest way for blockcommit-gitea (Go) to consume this library is via CLI:
import "os/exec"
out, err := exec.Command("scratch-git", "compare", "--old", oldPath, "--new", newPath, "--format", "json").Output()
// parse JSON