git-fast-import 0.1.1

A library for generating git fast-import streams
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented1 out of 8 items with examples
  • Size
  • Source code size: 39.86 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.77 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 18s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • orf

git-fast-import

A library for generating git fast-import streams.

This crate provides a simple, type-safe API for creating git commits programmatically by generating a stream that can be piped to git fast-import.

Example

use git_fast_import::{GitFastImporter, GITHUB_BOT_AUTHOR};
use std::process::{Command, Stdio};

fn main() {
    let mut child = Command::new("git")
        .args(["fast-import", "--quiet"])
        .stdin(Stdio::piped())
        .spawn()
        .expect("failed to spawn git fast-import");

    let stdin = child.stdin.take().unwrap();
    let mut importer = GitFastImporter::new(
        stdin,
        "main".to_string(),
        None,
        GITHUB_BOT_AUTHOR.to_string(),
    );

    let mut commit = importer.start_commit("Initial commit", chrono::Utc::now());
    commit.add_file("src/lib.rs", b"// new file").unwrap();
    commit.finish().unwrap();
    importer.finish().unwrap();

    let status = child.wait().expect("failed to wait on git fast-import");
    assert!(status.success());   
}

License

MIT