co-author

Crates.ioco-author
lib.rsco-author
version0.1.3
sourcesrc
created_at2023-10-15 13:06:56.40312
updated_at2024-04-24 15:50:39.52897
descriptionCo-Author your git commits from the command line
homepage
repositoryhttps://github.com/EricDriussi/co-author
max_upload_size
id1003702
size134,523
Eric Driussi (EricDriussi)

documentation

README

co-author

Give credit to your teammates when pairing or mob-programming.

co-author.webm

Use Case

It's useful to know who to ask when struggling with a piece of code.

Git blame is great, but it only mentions the committer, which leaves out the pair/mob partners.

It helps to know who else was involved (maybe the committer is busy or left the company long ago).

There are plenty of editor plugins (VSCode, JetBrains) that follow GitHub's guidelines for co-authoring commits.

This is a simple CLI tool that achieves the same thing, while being editor independent and easy to integrate into your existing workflows.

Installation

cargo install co-author

Usage

Co-author will look for an authors.csv file in your current working directory, falling back to $XDG_CONFIG_HOME/co-author/, $HOME/.config/co-author/, $HOME/.co-author/ and $HOME in that order.

This file should follow the structure alias,name,email:

j,John Doe,john@users.noreply.github.com
aj,Alice Johnson,alice@example.com
bb,Bob Brown,bob@example.com
e,Erica Lee,erica@example.com

If no options are passed, it will prompt you for a space-separated list of aliases and then for a commit message.

It will produce a commit message with the following structure:

a commit message


Co-Authored-by: John Doe <john@users.noreply.github.com>
Co-Authored-by: Erica Lee <erica@example.com>

If you group multiple users under the same alias, they will all be retrieved at once.

This is especially useful if you jump between various teams and would rather pick groups of people instead of individuals.

So for a file like:

j,John Doe,john@users.noreply.github.com
j,Jane Smith,jane@example.com

When given the alias j, it will add both users as co-authors.

Options

You can modify the behavior in a number of ways, most will bypass the prompt:

co-author -h
Co-Author your git commits from the command line

Usage: co-author [OPTIONS]

Options:
  -f, --file <FILE>        CSV file containing a list of authors (alias,name,email)
  -l, --list <LIST>        List of comma separated author aliases
  -a, --all                Use all available authors
  -m, --message <MESSAGE>  Specify commit message
  -e, --editor             Open default editor for commit message
  -p, --pre-populate       Pre-populate prompt/editor with (first line of) last commit message
  -s, --sort               Sort authors signatures when adding to commit message
      --amend              Amend last commit, both message and authors will be overwritten
      --fzf                Use fzf for author selection
  -h, --help               Print help
  -V, --version            Print version

--file

Specify a different authors file path.

--list

Use a pre-defined alias list.

This makes the alias selection scriptable. It also helps when working with different teams.

alias coa_proj_a="co-author --list a,b,c"
alias coa_proj_x="co-author --list x,y,z"

Omits the alias prompt.

--all

Use all the aliases in the file.

Conflicts with --list.

Omits the alias prompt.

--message

Just like git's -m: Specify a commit message.

Omits the message prompt.

--editor

Just like git's default behavior: Open a text editor to write the commit message.

It will look for the editor config in your git setup, falling back to $EDITOR, vim and vi in that order.

Omits the message prompt.

--pre-populate

Pre-populate either the prompt or the editor with the subject of the last commit message, so only the first line is recovered.

If you use Conventional Commits or other standards you might want the same general format, just with a different type or description.

Conflicts with --message.

--sort

Sort authors alphabetically by signature (username <email>).

If not used it will respect the order in the authors.csv file.

--amend

Amends the last commit, overwriting message and authors with the newly provided ones.

Enables --pre-populate flag under the hood.

--fzf

Depends on fzf being installed.

Presents a picker for the authors using your fzf install (and config). Uses the --multi flag, so pressing Tab will select multiple authors.

Press enter when done to continue with the commit message.

fzf.webm

Conflicts with --all and --list.

Commit count: 285

cargo fmt