vcs-diff 0.1.0

Shared git-format unified-diff model + parser and a version type for the vcs-toolkit-rs wrappers.
Documentation
  • Coverage
  • 100%
    33 out of 33 items documented1 out of 1 items with examples
  • Size
  • Source code size: 44.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 765.08 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ZelAnton/vcs-toolkit-rs
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ZelAnton

vcs-diff

Shared git-format unified-diff model and parser for the vcs-toolkit-rs workspace.

git diff and jj diff --git emit byte-identical output, so vcs-git and vcs-jj share one parser here instead of each carrying a copy that could silently drift. Dependency-free (std only) — pure data types and pure functions, no process execution.

use vcs_diff::{parse_diff, ChangeKind};

let diff = "diff --git a/f b/f\n--- a/f\n+++ b/f\n@@ -1 +1 @@\n-a\n+b\n";
for file in parse_diff(diff) {              // Vec<FileDiff>
    let verb = match file.change {          // ChangeKind is #[non_exhaustive]
        ChangeKind::Added => "added",
        ChangeKind::Deleted => "deleted",
        ChangeKind::Renamed => "renamed",
        _ => "modified",
    };
    println!("{verb} {}", file.path);
    for hunk in &file.hunks {               // Vec<Hunk> of DiffLine
        //    }
}

It also exposes [DiffStat] (the file/line aggregate both --shortstat and --stat parse into) and [Version] + [parse_dotted_version] for reading a <tool> --version banner.

The wrapper crates re-export these types, so vcs_git::FileDiff, vcs_git::parse_diff, and vcs_git::GitVersion (an alias of vcs_diff::Version) all resolve — you rarely name this crate directly.

Part of vcs-toolkit-rs; used by vcs-git, vcs-jj, and vcs-core.

License

MIT