gitcoauthor
v2.0.5
Published
CLI tool to add co-authors to git commits
Downloads
47
Readme
gitcoauthor
A CLI tool to easily add co-authors to your git commits.
Installation
npm install -g gitcoauthorUsage
After making a commit, run:
gitcoauthorThe tool will:
- Read your git history (last 250 commits by default)
- Present you with a list of unique authors
- Add the selected co-author to your most recent commit
The co-author will be added using the Git co-author convention:
Co-authored-by: Name <[email protected]>Options
--depth, -d <number>: Number of commits to search for authors (default: 250)
# Search only the last 50 commits
gitcoauthor --depth 50
# Search the last 1000 commits
gitcoauthor -d 1000Development
Setup
npm installBuild
npm run buildTest
# Run tests
npm testRun tests in watch mode
npm run test:watchGenerate coverage report
npm run test:coverageTesting Strategy
This project uses end-to-end (e2e) testing exclusively. All tests run the actual CLI in real git repositories, providing high confidence that the tool works correctly in production scenarios.
E2E Tests
- Test the actual CLI in real git repositories
- Create temporary git repos with commits
- Verify all functionality: command-line arguments, author detection, co-author addition, edge cases
- Located in
src/index.spec.ts - Run with
npm test
Test coverage includes:
- Command-line interface (
--help,--depthflag) - Git repository validation
- Author detection from commits and co-author strings
- Co-author parsing (whitespace, case insensitivity, multiple co-authors)
- Author deduplication
- Co-author addition and duplicate prevention
- Commit message preservation
- Input handling (cancellation, empty input)
Note: Interactive prompt testing (like ESC key handling) is limited because the prompts library requires a real TTY. When input is piped via stdin, the autocomplete behaves differently. Tests verify the CLI handles various inputs gracefully without crashing.
Publishing
The package is automatically published to npm when a new release is created on GitHub. The GitHub Action will:
- Run tests
- Build the TypeScript code
- Publish to npm with provenance
To publish manually:
- Update the version in
package.json - Create a git tag:
git tag v1.0.0 - Push the tag:
git push origin v1.0.0 - Create a release on GitHub
License
MIT
