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. The guard counts only
TRACKED modifications (--untracked-files=no): a revert never
touches untracked files, and a failure-recovery rollback runs right
after a release wrote dist/ — in repos that don’t gitignore their
dist, an untracked-counts-as-dirty guard would refuse every
post-release rollback. The one genuine hazard (an untracked file
where the revert must restore a tracked one) is refused by git
itself with an explicit “would be overwritten” error.
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.