Skip to content

hsbt/gh-coauthor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gh-coauthor

A GitHub CLI extension to easily add co-authors to your latest commit.

Overview

gh-coauthor is a command-line tool that makes it easy to add GitHub users as co-authors to your most recent Git commit. It automatically fetches user information from GitHub API and formats the co-authored-by trailer according to Git standards.

Installation

Prerequisites

Installing as a GitHub CLI extension

gh extension install hsbt/gh-coauthor

Manual Installation

  1. Clone this repository

    git clone https://github.com/hsbt/gh-coauthor.git
  2. Make the script executable

    chmod +x gh-coauthor/gh-coauthor
  3. Add the script to your PATH

Usage

Add a GitHub user as co-author to your most recent commit:

gh coauthor <username>

Show the tool version:

gh coauthor version

Display help information:

gh coauthor --help

Enable shell completion:

source <(gh coauthor completion)

Examples

# Add GitHub user 'pocke' as co-author to the latest commit
gh coauthor pocke

# Show version information
gh coauthor version

Environment Variables

  • COAUTHOR_DEBUG=1 - Enable debug output

How it works

gh-coauthor automatically:

  1. Retrieves user details from the GitHub API
  2. Tries to find the user's email using various methods:
    • From GitHub API (if public)
    • From existing git history
    • Falls back to GitHub's noreply email format
  3. Amends the most recent commit to add the co-author trailer

Development

Testing

This project uses Bats (Bash Automated Testing System) for testing.

To run the tests:

  1. Install Bats:

    # On macOS with Homebrew
    brew install bats-core
    
    # On Ubuntu
    sudo apt-get install bats
    
    # Or from source
    git clone https://github.com/bats-core/bats-core.git
    cd bats-core
    ./install.sh /usr/local
  2. Run the tests:

    bats test/

The test suite includes tests for:

  • Basic functionality verification
  • Command options and flags
  • Error handling
  • Email fallback mechanisms

Acknowledgments

The original script for this tool was created by pocke and is available at https://gist.github.com/pocke/c54be87893aefa2be76abe1b2a4cdca5.

The command structure and organization were inspired by gh-signoff from Basecamp.

License

MIT

About

A GitHub CLI extension to easily add co-authors to your latest commit.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages