Skip to content

Commit db49355

Browse files
author
Test
committed
Initial commit
0 parents  commit db49355

21 files changed

Lines changed: 1362 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version: "1.22"
21+
cache: true
22+
23+
- name: Download dependencies
24+
run: go mod download
25+
26+
- name: Run tests
27+
run: go test -race -coverprofile=coverage.out ./...
28+
29+
- name: Build binary
30+
run: go build -o git-stats ./cmd/git-stats
31+
32+
- name: Upload coverage
33+
uses: actions/upload-artifact@v4
34+
with:
35+
name: coverage
36+
path: coverage.out

‎.github/workflows/release.yml‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version: "1.22"
22+
cache: true
23+
24+
- name: Run GoReleaser
25+
uses: goreleaser/goreleaser-action@v6
26+
with:
27+
version: "~> v2"
28+
args: release --clean
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

‎.gitignore‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Binaries
2+
git-stats
3+
/bin/
4+
/dist/
5+
6+
# Go
7+
*.exe
8+
*.exe~
9+
*.dll
10+
*.so
11+
*.dylib
12+
*.test
13+
*.out
14+
coverage.out
15+
coverage.html
16+
17+
# IDE
18+
.idea/
19+
.vscode/
20+
*.swp
21+
*.swo
22+
23+
# OS
24+
.DS_Store
25+
Thumbs.db
26+
27+
# Reports generated locally
28+
report.html
29+
report.md
30+
report.json

‎.goreleaser.yaml‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
version: 2
2+
3+
project_name: git-stats-cli
4+
5+
before:
6+
hooks:
7+
- go mod tidy
8+
- go test ./...
9+
10+
builds:
11+
- id: git-stats
12+
main: ./cmd/git-stats
13+
binary: git-stats
14+
env:
15+
- CGO_ENABLED=0
16+
goos:
17+
- linux
18+
- darwin
19+
- windows
20+
goarch:
21+
- amd64
22+
- arm64
23+
ldflags:
24+
- -s -w
25+
26+
archives:
27+
- id: default
28+
formats:
29+
- tar.gz
30+
format_overrides:
31+
- goos: windows
32+
formats:
33+
- zip
34+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
35+
36+
checksum:
37+
name_template: "checksums.txt"
38+
39+
changelog:
40+
sort: asc
41+
filters:
42+
exclude:
43+
- "^docs:"
44+
- "^chore:"
45+
46+
release:
47+
github:
48+
owner: loSpaccaBit
49+
name: git-stats-cli
50+
draft: false
51+
prerelease: auto
52+
53+
snapshot:
54+
name_template: "{{ incpatch .Version }}-next"

‎Dockerfile‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# syntax=docker/dockerfile:1
2+
3+
FROM golang:1.22-alpine AS builder
4+
5+
WORKDIR /src
6+
RUN apk add --no-cache git ca-certificates
7+
8+
COPY go.mod go.sum ./
9+
RUN go mod download
10+
11+
COPY . .
12+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /git-stats ./cmd/git-stats
13+
14+
FROM alpine:3.20
15+
16+
RUN apk add --no-cache ca-certificates
17+
COPY --from=builder /git-stats /usr/local/bin/git-stats
18+
19+
ENTRYPOINT ["git-stats"]
20+
CMD ["--help"]

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Francesco Nocerino (loSpaccaBit)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# git-stats-cli
2+
3+
[![CI](https://github.com/loSpaccaBit/git-stats-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/loSpaccaBit/git-stats-cli/actions/workflows/ci.yml)
4+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5+
[![Go Report Card](https://goreportcard.com/badge/github.com/loSpaccaBit/git-stats-cli)](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).

‎go.mod‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
module github.com/loSpaccaBit/git-stats-cli
2+
3+
go 1.25.1
4+
5+
require (
6+
github.com/fatih/color v1.19.0
7+
github.com/go-git/go-git/v5 v5.19.1
8+
github.com/olekukonko/tablewriter v0.0.5
9+
github.com/spf13/cobra v1.10.2
10+
github.com/stretchr/testify v1.11.1
11+
)
12+
13+
require (
14+
dario.cat/mergo v1.0.0 // indirect
15+
github.com/Microsoft/go-winio v0.6.2 // indirect
16+
github.com/ProtonMail/go-crypto v1.1.6 // indirect
17+
github.com/clipperhouse/uax29/v2 v2.6.0 // indirect
18+
github.com/cloudflare/circl v1.6.3 // indirect
19+
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
20+
github.com/davecgh/go-spew v1.1.1 // indirect
21+
github.com/emirpasic/gods v1.18.1 // indirect
22+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
23+
github.com/go-git/go-billy/v5 v5.9.0 // indirect
24+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
25+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
26+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
27+
github.com/kevinburke/ssh_config v1.2.0 // indirect
28+
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
29+
github.com/mattn/go-colorable v0.1.14 // indirect
30+
github.com/mattn/go-isatty v0.0.20 // indirect
31+
github.com/mattn/go-runewidth v0.0.19 // indirect
32+
github.com/pjbgf/sha1cd v0.6.0 // indirect
33+
github.com/pmezard/go-difflib v1.0.0 // indirect
34+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
35+
github.com/skeema/knownhosts v1.3.1 // indirect
36+
github.com/spf13/pflag v1.0.9 // indirect
37+
github.com/xanzy/ssh-agent v0.3.3 // indirect
38+
golang.org/x/crypto v0.50.0 // indirect
39+
golang.org/x/net v0.53.0 // indirect
40+
golang.org/x/sys v0.43.0 // indirect
41+
gopkg.in/warnings.v0 v0.1.2 // indirect
42+
gopkg.in/yaml.v3 v3.0.1 // indirect
43+
)

0 commit comments

Comments
 (0)