Giter VIP home page Giter VIP logo

git-author's Introduction

VMware has ended active development of this project, this repository will no longer be updated.


git-author

A simple tool to add multiple authors to commit messages. Under the hood it is based on git commit --template and depends on git-together.

Setup

Installation

Because git-author is a shell wrapper around git-together, both must be installed on the system.

MacOS

brew install pivotal/tap/git-author

Linux

The git-together and git-author executables must be installed somewhere on your path so that git recognizes commands that begin with git together or git author.

Install and configure git-together

You can follow the instructions here: https://github.com/kejadlen/git-together We suggest using git config --global for the following instructions, since it's better to share the same git-together settings across all repos.

For your convenience, only the necessary settings are repeated here:

# include git-together configuration in ~/.gitconfig
git config --global --add include.path ~/.git-together

# Add the below line to your .bashrc to disable the
# `--signoff`s added by `git-together commit`.
export GIT_TOGETHER_NO_SIGNOFF=1

Note: Because git-author calls git-together directly to generate a commit template file, aliasing git to git-together is not strictly necessary, unless you want git author info to alternate among members of the pair or mob as you make commits. With Co-authored-by: in the commit message, Github will show all authors regardless of the git author info.

Install git-author

git clone [email protected]:pivotal/git-author
./git-author/setup.sh

Usage

Set the authors as below:

# pairing with James and Naomi
git author jh nn

# soloing
git author jh

# mobbing
git author jh nn ca

# show who are included in current ~/.git-author-template
git author

After doing so, git commit will now automatically include all of the authors in the commit message with the prefix Co-authored-by: or Authored-by if there is only one author. For example:

# mobbing
git author jh nn ca

# commit
git commit

# the commit message is pre-populated as:


Co-authored-by: James Holden <[email protected]>
Co-authored-by: Naomi Nagata <[email protected]>
Co-authored-by: Chrisjen Avasarala <[email protected]>


# soloing
git author ca

# commit
git commit

# the commit message is pre-populated as:


Authored-by: Chrisjen Avasarala <[email protected]>

Story Numbers

Often when making commits, we like to append the commit message with a story number, e.g. [#12345678]. To automate this process, you can set the $STORY_NUM environment variable to a value such as '#12345678 story title'. Run git author again for the story number to appear in the commit message. This will result in the below being appended to the commit message template:

[#12345678]
# story title

Co-authored-by: ...
Co-authored-by: ...

Additionally, if you set git config --global git-author.includeBlankStoryNum true, then if you didn't set $STORY_NUM, empty story number brackets ('[]') will be appended to prompt you to fill it in.

Global vs. Local git-together Settings

By default, git-together will be called with --global, hence a system-wide configuration of authors are set.

However, for special cases, people like to use non-global configurations just for given set of git repos. To support that usage, we introduced another environment variable GIT_AUTHOR_LOCAL.

If this variable it set git-together will be called without --global flag. Here is the example usage for non-global usage:

GIT_AUTHOR_LOCAL=1 git author jh

If people always wants to use it without --global, then can put this environment in their shell environment, e.g. .bashrc.

Why

git-together is a wonderful tool to change the author and commit fields in the git commit object, and rotate the authors automatically to evenly distribute the credit.

However, both the git author and commit fields may change or be lost in the future due to merging, rebasing, and cherry-picking.

Also, git-together cannot put multiple authors directly into same commit, e.g. it only supports one Signed-off-by: message generated by git commit --signoff.

git-author is created to extend the git-together capability, so that all the authorship information will be captured as part of the commit message, hence, it won't care about who actually tracked in the author and commit fields in the git log.

See this discussion on the open source GPDB project's mailing list: https://groups.google.com/a/greenplum.org/forum/#!msg/gpdb-dev/qHqa9UbFpSA/u0Y0g2rqAAAJ

Development

git-author is a bash script, we used bats to verify the functionality of this script.

# run the tests
make

You are welcome to extend this utility. Please make sure adding new tests to cover your scenario first.

git-author's People

Contributors

khuddlefish avatar professor avatar rlewis24 avatar xinzweb avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

git-author's Issues

brew issue

I was installing git-author via brew and had an interesting experience.

I could see that brew was running both of the following lines

    system "touch ~/.git-author-template"
    system "git config --global commit.template ~/.git-author-template"

However, the file ~/.git-author-template did not exist on the file system

I'm wondering if brew does not run as the current user.

Any thoughts?

Cloning the repo and running setup.sh worked fine

STORY_NUM is easy to miss after author is set

Considering you already have pair setup git author alice bob, and they are working on story 1111. then they have to do the export STORY_NUM first, then do the git author to set it.

Once, they move on to the next story, they set the STORY_NUM, but then they have to do git author again to let it refreshed to the template.

Proposal

How about we just do git author alice bob #1111 to directly set the story number into the template other than depends on the STORY_NUM?

Would love a Windows version of this.

Windows is the OS for programmers in the Enterprise relying heavily on Microsoft Ecosystem. Need a PowerShell script which could potentially setup this on Windows.

git author pulls author info both global and local git configs when using commit aliases

This took the CAPI team an eternity to track down, but when using git-author , we've noticed some inconsistency in whose names get applied to a commit if folks use aliases in combination with raw git with. Some folks here have reflexes around ci for "commit" and with for author, and it's been causing lots of havoc.

The bug is basically this:

git config --file ~/.gitconfig --add git-together.aliases ci
git config --file ~/.gitconfig --add alias.ci commit --verbose
git with cb am
git author cs sj
git ci
git show --format=full
commit 7fff7d131ea08e5c58fdb4c60aa5caacd9780947 (HEAD -> master)
Author: Connor Braa <[email protected]>
Commit: Andres Medina <[email protected]>

    wat

    Co-authored-by: Chris Selzo <[email protected]>
    Co-authored-by: Sannidhi Jalukar <[email protected]>

The git with command sets the local repo's .git/config file's git-together.active, and git author (correctly) sets the same in ${HOME}/.gitconfig, and we end up with surprising commit messages because the local state sticks around in places where we wouldn't expect.

git-author should work in single-repo configuration

After #17 was merged, git-author appears to assume that it's being uses system-wide.

I'm in a position where I want to use git-author in just one repository. The authors for this one repository don't work on other projects on my workstation and I don't want to accidentally commit as them.

Reproduction Steps

# Install the two tools
brew install pivotal/tap/git-together pivotal/tap/git-author
$(brew --prefix git-author)/bin/setup.sh

# Create a new git repo
mkdir repro && cd repro
git init

# Set up local pairs
git config --add include.path ../.git-together
git config --file .git-together --add git-together.domain example.com
git config --file .git-together --add git-together.authors.ab 'Abigail Bave; abigail.bave'
git config --file .git-together --add git-together.authors.cd 'Chris Daunders; chris.daunders'
git author ab cd

Actual Results

git author ab cd
Error: author not found for 'ab'
Caused by: error getting git config for 'git-together.authors.ab'
Caused by: config value 'git-together.authors.ab' was not found; class=Config (7); code=NotFound (-3)

Expected Results

git author ab cd
Co-authored-by: Abigail Bave <[email protected]>
Co-authored-by: Chris Daunders <[email protected]>

unable to install automatically without pivotal org ssh keys

The CF CAPI team would love to use git-author, but we cannot automatically install it via Brewfile or by scripting because the permissions here require that one is logged in to the Pivotal org. ๐Ÿ˜ข We perform unattended installs and upgrades of our workspace machines, and would prefer for this to roll out to all of them simultaneously and automatically.

Please make this public or fix the Brew formula. It'd be very much appreciated.

Thanks, and excited to be rid of git-duet! ๐ŸŽ‰

git author brew tap doesn't work properly

We followed the instructions in README.md to brew install pivotal/tap/git-author. After doing this, we were able to successfully run git author ak sb and it printed out the git commit template. However, even after reloading the terminal, git commit -v was not using the git commit template.

To solve the issue, we had to brew uninstall pivotal/tap/git-author and then run the setup.sh which worked perfectly.

Possible solution:

  1. Fix the problem in the homebrew tap
  2. Remove the Mac OS instructions from the README.md and just use Linux instructions for everyone

Note the issue may have to do with the git-together tap not properly installing.

Reference: pivotal/homebrew-tap

w/ @xinzweb

clearer name for the template

Hi there, Xin and I were talking and we weren't able to come up with a better name for the template file. Right now, it's ~/.git-author which is confusingly adjacent to ~/.git-authors (from git-duet) or other similar files. We want a name that emphasizes that it's a transitory file: as you git author ab cd, this file changes (whereas other similarly named files are much more static).

Leading idea: ~/.git-author.template, but other possible options are:
git-author-authors
git-author-message
git-author-template

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.