|
| 1 | +# git-stats-cli |
| 2 | + |
| 3 | +[](https://github.com/loSpaccaBit/git-stats-cli/actions/workflows/ci.yml) |
| 4 | +[](LICENSE) |
| 5 | +[](https://goreportcard.com/report/github.com/loSpaccaBit/git-stats-cli) |
| 6 | + |
| 7 | +A command-line tool to analyze Git repositories and generate insightful reports — without requiring the `git` binary installed. |
| 8 | + |
| 9 | +Built with **Go**, **Cobra**, and **go-git**. |
| 10 | + |
| 11 | +## Features |
| 12 | + |
| 13 | +- Analyze local repositories with `git-stats analyze` |
| 14 | +- Terminal output with colored tables (disable with `--no-color`) |
| 15 | +- Export reports as JSON, Markdown, or HTML |
| 16 | +- Cross-platform binaries via GoReleaser |
| 17 | +- Docker support |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +### Go install |
| 22 | + |
| 23 | +```bash |
| 24 | +go install github.com/loSpaccaBit/git-stats-cli/cmd/git-stats@latest |
| 25 | +``` |
| 26 | + |
| 27 | +### Docker |
| 28 | + |
| 29 | +```bash |
| 30 | +docker build -t git-stats-cli . |
| 31 | +docker run --rm -v "$(pwd):/repo" git-stats-cli analyze /repo |
| 32 | +``` |
| 33 | + |
| 34 | +### GitHub Releases |
| 35 | + |
| 36 | +Download the latest binary for your OS from [Releases](https://github.com/loSpaccaBit/git-stats-cli/releases). |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +### Analyze a repository |
| 41 | + |
| 42 | +```bash |
| 43 | +git-stats analyze . |
| 44 | +git-stats analyze /path/to/repo |
| 45 | +git-stats --no-color analyze . |
| 46 | +``` |
| 47 | + |
| 48 | +Output includes: |
| 49 | + |
| 50 | +- Total commits |
| 51 | +- Top authors by commit count |
| 52 | +- Languages detected from file extensions |
| 53 | +- Activity in the last 30 and 90 days |
| 54 | + |
| 55 | +### Generate a report |
| 56 | + |
| 57 | +```bash |
| 58 | +git-stats report --format=json --output=report.json . |
| 59 | +git-stats report --format=md --output=report.md . |
| 60 | +git-stats report --format=html --output=report.html . |
| 61 | +``` |
| 62 | + |
| 63 | +## Tech Stack |
| 64 | + |
| 65 | +| Layer | Technology | |
| 66 | +|-------|------------| |
| 67 | +| Language | Go 1.22+ | |
| 68 | +| CLI | Cobra | |
| 69 | +| Git parsing | go-git | |
| 70 | +| Terminal output | fatih/color, tablewriter | |
| 71 | +| Reports | encoding/json, text/html templates | |
| 72 | +| Testing | testing + testify | |
| 73 | +| CI/CD | GitHub Actions + GoReleaser | |
| 74 | + |
| 75 | +## Project Structure |
| 76 | + |
| 77 | +``` |
| 78 | +git-stats-cli/ |
| 79 | +├── cmd/git-stats/ # CLI entrypoint |
| 80 | +├── internal/ |
| 81 | +│ ├── analyzer/ # Repository analysis logic |
| 82 | +│ ├── formatter/ # JSON, Markdown, HTML, terminal output |
| 83 | +│ ├── git/ # go-git wrapper |
| 84 | +│ └── report/ # Report generation |
| 85 | +├── pkg/stats/ # Shared data models |
| 86 | +└── .github/workflows/ # CI and release pipelines |
| 87 | +``` |
| 88 | + |
| 89 | +## Development |
| 90 | + |
| 91 | +### Prerequisites |
| 92 | + |
| 93 | +- Go 1.22+ |
| 94 | +- Git (for development only; runtime uses go-git) |
| 95 | + |
| 96 | +### Setup |
| 97 | + |
| 98 | +```bash |
| 99 | +git clone https://github.com/loSpaccaBit/git-stats-cli.git |
| 100 | +cd git-stats-cli |
| 101 | +go mod download |
| 102 | +``` |
| 103 | + |
| 104 | +### Run tests |
| 105 | + |
| 106 | +```bash |
| 107 | +go test ./... |
| 108 | +``` |
| 109 | + |
| 110 | +### Build locally |
| 111 | + |
| 112 | +```bash |
| 113 | +go build -o git-stats ./cmd/git-stats |
| 114 | +./git-stats analyze . |
| 115 | +``` |
| 116 | + |
| 117 | +## Releasing |
| 118 | + |
| 119 | +Tag a version to trigger GoReleaser: |
| 120 | + |
| 121 | +```bash |
| 122 | +git tag v0.1.0 |
| 123 | +git push origin v0.1.0 |
| 124 | +``` |
| 125 | + |
| 126 | +## License |
| 127 | + |
| 128 | +MIT — see [LICENSE](LICENSE). |
0 commit comments