@tmegit/git-activity-tracer
v1.0.2
Published
Track your development activity across GitHub and GitLab. Fetch commits, pull/merge requests, and code reviews from your authenticated accounts.
Maintainers
Readme
Git Activity Tracer
Track your development activity across GitHub and GitLab. Fetch commits, pull/merge requests, and code reviews from your authenticated accounts.
Quick Start
# Try it now with npx
npx @tmegit/git-activity-tracer # Fetch current weekFirst time setup:
- Get a token: GitHub or GitLab
- Set environment variable:
export GH_TOKEN=your_token_here(orGITLAB_TOKEN) - Run:
npx @tmegit/git-activity-tracer
Install globally (optional):
npm install -g @tmegit/git-activity-tracer
git-activity-tracer # Fetch current week
git-activity-tracer 2025-01-01 2025-01-31 # Specific rangeCommon Commands
# Current week activity
git-activity-tracer
# Specific date range
git-activity-tracer 2025-01-01 2025-01-31
# Export formats
git-activity-tracer --format json
git-activity-tracer --format csv
# All commits from all branches
git-activity-tracer all-commits
# Include URLs in output
git-activity-tracer --with-linksEnvironment Variables
| Variable | Required | Description | Default |
| -------------- | --------- | ------------------------------------- | -------------------- |
| GH_TOKEN | One of * | GitHub personal access token | - |
| GITLAB_TOKEN | One of * | GitLab personal access token | - |
| GITLAB_HOST | No | GitLab instance URL (for self-hosted) | https://gitlab.com |
*At least one token (GitHub or GitLab) is required. Both can be used simultaneously.
Command Options
| Option | Description | Default |
| ------------------- | ---------------------------------------------- | ---------------------- |
| <fromdate> | Start date (YYYY-MM-DD) | Monday of current week |
| <todate> | End date (YYYY-MM-DD) | Today |
| --with-links | Include URLs in console output | false |
| --format <format> | Output format: console, json, or csv | console |
| config | Display configuration file location | - |
| project-id | Manage repository project ID mappings | - |
| all-commits | Show all commits from all branches (see below) | - |
All Commits Command
Show all commits from all branches (including feature branches):
git-activity-tracer all-commits # Current week
git-activity-tracer all-commits 2025-12-01 2025-12-31 # Date range
git-activity-tracer all-commits --format csv # ExportDifference from default:
- Default: Commits from base branches (main/master/develop) + PRs + reviews
- all-commits: ALL commits from ALL branches (including feature branches)
Project ID Mapping
Map repositories to project IDs for billing and time tracking:
git-activity-tracer project-id add owner/repository PROJECT-123
git-activity-tracer project-id list
git-activity-tracer project-id remove owner/repositoryProject IDs automatically appear in all output formats (console, JSON, CSV).
Configuration
Configuration file: ~/.git-activity-tracer/config.json (auto-created on first run)
# View configuration location
git-activity-tracer configCustom Base Branches
Note: Base branch configuration applies only to GitLab. GitHub automatically uses the default branch via the GraphQL API and does not require configuration.
Default branches tracked (GitLab only): main, master, develop, development
To add more branches for GitLab, edit the configuration file:
{
"baseBranches": ["main", "master", "develop", "development", "trunk", "staging"],
"repositoryProjectIds": {
"owner/repository": "PROJECT-123"
}
}Platform differences:
- GitHub: Uses GraphQL
contributionsCollectionAPI which automatically provides commits from the default branch. ThebaseBranchesconfiguration is not used. - GitLab: Filters push events by the configured
baseBranchesto determine which commits to include in reports. - Both platforms:
all-commitscommand ignores base branch configuration and returns commits from all branches.
Self-Hosted GitLab
export GITLAB_HOST=https://gitlab.your-company.com
export GITLAB_TOKEN=your_token_hereDevelopment
pnpm install # Install dependencies
pnpm start # Run in development
pnpm test # Run tests
pnpm run lint # Lint code
pnpm run format # Format code
pnpm build # Build for distributionContributing
This project uses Conventional Commits for automated versioning:
feat:- New feature (minor bump: 1.0.0 → 1.1.0)fix:- Bug fix (patch bump: 1.0.0 → 1.0.1)feat!:orBREAKING CHANGE:- Breaking change (major bump: 1.0.0 → 2.0.0)docs:,style:,refactor:,perf:,test:,chore:- No version bump
Commits to main trigger automated releases via semantic-release.
API Limitations
- GitHub: Up to 50 repositories, 100 commits per repository
- GitLab: Up to 1000 events and 1000 merge requests per query
License
Apache-2.0 License © Felix Anhalt
