Skip to main content

rotate_authors

Function rotate_authors 

Source
pub fn rotate_authors(
    config: &mut dyn Vcs,
    strategy: RotationOption,
) -> Result<()>
Expand description

Rotate the primary author among configured authors

Moves the first coauthor to become the primary author, and demotes the current primary to be the last coauthor. This affects the NEXT commit (git reads user.name/email before the prepare-commit-msg hook runs).

§Errors

Returns an error if:

  • Reading git config (user.name, user.email, or coauthors) fails
  • Writing git config (removing old coauthors or setting new authors) fails

§Panics

This function will panic if the primary author (constructed from user.name and user.email) is None. However, this is prevented by an early return check: if either user.name or user.email is missing, the function returns Ok(()) without attempting to unwrap. The unwrap on line 47 is safe because at that point we’ve confirmed both name and email exist.