blame

Function blame 

Source
pub fn blame<'a, T>(
    revisions: &'a [BlameRevision<'a, T>],
) -> Result<BlameResult<'a, T>, BlameError>
Expand description

Performs a blame operation on a sequence of revisions to determine the origin of each line.

This function takes a slice of BlameRevision objects ordered chronologically (oldest to newest) and computes which revision each line in the final version originated from.

§Arguments

  • revisions - A slice of revisions ordered chronologically (oldest first, newest last)

§Returns

Returns a BlameResult containing each line of the final revision along with metadata about which revision introduced that line.

§Errors

Returns BlameError::EmptyRevisions if the revisions slice is empty.

§Example

use blame_rs::{blame, BlameRevision};
use std::rc::Rc;

#[derive(Debug)]
struct CommitInfo {
    hash: String,
    author: String,
}

let revisions = vec![
    BlameRevision {
        content: "line 1\nline 2",
        metadata: Rc::new(CommitInfo { hash: "abc123".into(), author: "Alice".into() }),
    },
    BlameRevision {
        content: "line 1\nline 2\nline 3",
        metadata: Rc::new(CommitInfo { hash: "def456".into(), author: "Bob".into() }),
    },
];

let result = blame(&revisions)?;