Skip to main content

score_diff

Function score_diff 

Source
pub fn score_diff(diff: &str) -> Result<JitDiffReport, Error>
Available on crate feature vcs-git only.
Expand description

Score an arbitrary unified diff for just-in-time defect-induction risk (issue #580).

Unlike score_commit, a bare diff carries no author, parent, or file history, so only the size and diffusion feature groups are computable. The result is a partial jit::JitDiffReport whose history / experience / purpose groups are absent from the type (not present as zero), and whose partial_risk_score is not comparable to a commit score — rank diffs against other diffs only. See jit::JitDiffReport for the full contract.

diff must be a git-style unified diff carrying diff --git file headers (as produced by git diff / git format-patch), with one or more file stanzas. Plain diff -u output without those headers and combined / merge diffs (git diff --cc, @@@ headers) are not supported. No repository access is needed; options does not participate (a bare diff has nothing to window).

§Errors

Returns Error::InvalidDiff when the diff is structurally malformed (a bad @@ hunk header, or a +/- body line outside any hunk) or carries diff content with no diff --git file header at all (plain diff -u or a combined/merge diff).