gccrs-tools 0.2.0

Various tools and modules to help develop gccrs tooling and interact with the project
Documentation
// help = "Flag to indicate gccrs-prefixer is being used during a git rebase. This flag makes gccrs-prefixer a lot more automatic and complete, and enables you to do a `git rebase -x gccrs-prefixer`",

use anyhow::{bail, Result};
use std::process::{Command, Stdio};

fn main() -> Result<()> {
    let commit = Command::new("git")
        .args(["log", "-1", "--format=%B"])
        .stdout(Stdio::piped())
        .output()?
        .stdout;

    let commit = String::from_utf8(commit)?;

    let commit = gccrs_tools::Commit::new(commit);

    let prefixed_commit = commit.maybe_prefix();

    let status = Command::new("git")
        .args(["commit", "--amend", "-m", &prefixed_commit])
        .status()?;

    if status.success() {
        Ok(())
    } else {
        bail!("error when amending commit with new message:\n{prefixed_commit}")
    }
}