Code Monkey home page Code Monkey logo

git-co-author's Introduction

git-co-author

Easily use 'Co-authored-by' trailers in the commit template.

usage: git co-author                Show co-authors in commit template
   or: git co-author <initials>...  Update co-authors in commit template
   or: git co-author clear          Remove all co-authors from commit template
   or: git co-author authors        List authors in git config
   or: git co-author find           Find authors in git log

This command enables pairs and mobs of programmers to attribute commits to all the authors. For convenience, co-authors are added using their initials. Their names and email addresses are stored in git config.

GitHub has first-class support for Co-authored-by trailers and recognises the author and co-authors of commits. For more information on co-authoring commits, see:

Install

Install the command using Homebrew:

brew install jamesjoshuahill/tap/git-co-author

Or manually into your $PATH, for example:

curl -O https://raw.githubusercontent.com/jamesjoshuahill/git-co-author/master/git-co-author
install git-co-author /usr/local/bin/

Configure the commit template path, for example:

git config --global commit.template '~/.git-commit-template'

Ensure there is a commit template file:

touch ~/.git-commit-template

Add authors to git config

Configure the name and email address of authors with their initials. For example Ann and Bob:

git config --global co-authors.aa 'Ann Author <[email protected]>'
git config --global co-authors.bb 'Bob Book <[email protected]>'

The co-authors will appear in your global git config:

[co-authors]
    aa = Ann Author <[email protected]>
    bb = Bob Book <[email protected]>

You must use an email address associated with the co-author's GitHub account.

Tip: You can help a co-author find their preferred email address by sharing this information:

  • To find your GitHub-provided no-reply email, navigate to your email settings page under "Keep my email address private."
  • To find the email you used to configure Git on your computer, run git config user.email on the command line.

Usage

This command expects you to commit using the commit template. If you run git commit with the message option -m/--message then the commit template is not used and any Co-authored-by trailers in the commit template won't be commited.

Pair with Ann:

$ git co-author aa
Co-authored-by: Ann Author <[email protected]>

Mob with Ann and Bob:

$ git co-author aa bb
Co-authored-by: Ann Author <[email protected]>
Co-authored-by: Bob Book <[email protected]>

Solo (without co-authors):

$ git co-author clear

List authors in git config:

$ git co-author authors
aa  'Ann Author <[email protected]>'
bb  'Bob Book <[email protected]>'

Find authors in git log:

$ git co-author find
Ann Author <[email protected]>
Bob Book <[email protected]>

Test

The command is tested using the Bats testing framework for Bash.

The tests expect no global git config, so they are run in a container to isolate them.

Docker

Install Docker:

brew cask install docker

Build the test image:

docker build -t git-co-author-test .

Run the tests in a container:

docker run git-co-author-test

For active development you can mount the host directory into the test container, so that you can edit the code locally and run the tests in the container repeatedly:

$ docker run --volume "$PWD:/git-co-author" -it git-co-author-test bash
bash-5.0# ./test/git-co-author.bats

Notes

  • The command does not modify Git config.
  • This approach assumes the user has configured user.name and user.email so that they are attributed as an author.
  • Only the Co-authored-by trailers in the commit template file are modified or removed. The rest of the commit template is unaffected.
  • GitHub deduplicates multiple authors of a commit, so if you commit as author and co-author you will only be shown once.
  • Config in the current Git repo takes precedence over global Git config. To set config for one repo use the git config --local option.
  • Inspired by git-author.

git-co-author's People

Contributors

jamesjoshuahill avatar joshua-hill-form3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

indebted jtzero

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.