Skip to main content

revert_commit_in

Function revert_commit_in 

Source
pub fn revert_commit_in(
    cwd: &Path,
    sha: &str,
    message: Option<&str>,
    identity: &CommitterIdentity,
) -> Result<()>
Expand description

Run git revert --no-edit <sha> in cwd, optionally followed by git commit --amend -m <message>.

Refuses against a dirty working tree (git revert would surface a less actionable “your local changes would be overwritten” message otherwise). Mirrors the dirty-tree guard used by stage-publish/src/util/git_revert.rs.

On revert failure (typically a merge conflict against later commits on top of the bump), runs git revert --abort to restore the working tree before bubbling the error — otherwise the next rollback attempt would trip the dirty-tree guard and the operator would be stuck.

identity is threaded through as committer env vars so the call works on bare-CI hosts where the workflow checkout doesn’t set user.email / user.name. The env is scoped to the spawn; the repo’s git config is never mutated.