{"id":49179530,"url":"https://github.com/admbahm/pushbadger","last_synced_at":"2026-04-23T01:00:44.275Z","repository":{"id":353207343,"uuid":"1218415612","full_name":"admbahm/PushBadger","owner":"admbahm","description":"Deterministic git diff analyzer that maps changed files to risk areas using path-based heuristics. Fast, reproducible, no AI.","archived":false,"fork":false,"pushed_at":"2026-04-22T23:10:45.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-22T23:30:58.412Z","etag":null,"topics":["cli","code-review","developer-tools","git","go","risk-analysis","sre","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/admbahm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-22T21:19:37.000Z","updated_at":"2026-04-22T23:10:49.000Z","dependencies_parsed_at":"2026-04-23T01:00:40.705Z","dependency_job_id":null,"html_url":"https://github.com/admbahm/PushBadger","commit_stats":null,"previous_names":["admbahm/pushbadger"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/admbahm/PushBadger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admbahm%2FPushBadger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admbahm%2FPushBadger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admbahm%2FPushBadger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admbahm%2FPushBadger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/admbahm","download_url":"https://codeload.github.com/admbahm/PushBadger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/admbahm%2FPushBadger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32161325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T17:06:48.269Z","status":"ssl_error","status_checked_at":"2026-04-22T17:06:19.037Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","code-review","developer-tools","git","go","risk-analysis","sre","static-analysis"],"created_at":"2026-04-23T01:00:36.030Z","updated_at":"2026-04-23T01:00:44.250Z","avatar_url":"https://github.com/admbahm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PushBadger\n\nPushBadger analyzes git diffs and maps changed files to risk areas using\ndeterministic, path-based heuristics. No AI — just fast, reproducible signal\nabout which parts of your codebase are touched by a change.\n\n## Requirements\n\n- Go 1.24+\n- git\n\n## Install\n\n**Build from source:**\n\n```sh\ngit clone \u003crepo-url\u003e\ncd pushbadger\nmake build          # produces ./pushbadger\n```\n\nOr without Make:\n\n```sh\ngo build -o pushbadger ./cmd/pushbadger\n```\n\n\u003e A versioned binary release is planned. Until then, build from source.\n\u003e `go install` requires the module to be published at a public module path,\n\u003e which has not been done yet.\n\n## Usage\n\n```\npushbadger analyze [flags]\n\nFlags:\n  --base string    Base ref for diff (default: auto-detected)\n  --head string    Head ref for diff (default: HEAD)\n  --staged         Diff staged changes  (HEAD → index)\n  --working        Diff unstaged changes (index → worktree)\n  --format string  Output format: text or json (default: text)\n  --rules string   Path to custom rules YAML file\n```\n\n**Diff modes** — pick at most one group; combining `--staged` or `--working`\nwith `--base`/`--head` exits 2 with a specific error message:\n\n| Command | What it diffs |\n|---|---|\n| `pushbadger analyze` | `\u003cresolved-base\u003e...HEAD` |\n| `pushbadger analyze --staged` | staged changes (HEAD → index) |\n| `pushbadger analyze --working` | unstaged changes (index → worktree) |\n| `pushbadger analyze --base X` | `X...HEAD` |\n| `pushbadger analyze --head Y` | `\u003cresolved-base\u003e...Y` |\n| `pushbadger analyze --base X --head Y` | `X...Y` |\n\n**Base branch resolution** (in order):\n1. `--base` flag\n2. `git symbolic-ref refs/remotes/origin/HEAD`\n3. First of `main`, `master`, `trunk` that exists\n4. Hard fail (exit 2) if none found\n\n## How matching works\n\nEach rule defines a named area, a priority, and a list of\n[doublestar](https://github.com/bmatcuk/doublestar) glob patterns. On each run:\n\n1. The changed file list is collected from `git diff`.\n2. Every file path is normalized to lowercase before pattern matching.\n3. Each file is tested against every rule's patterns in priority order.\n4. A file may match multiple areas and will appear in each matched area.\n5. Files that match no rule are collected into the `unclassified` area, which\n   is always sorted last regardless of how many areas matched.\n6. Within each area, files are sorted by path. Areas are sorted by priority\n   (ascending), then by name for ties.\n\n### Matching examples\n\nUsing the default embedded ruleset:\n\n| File path | Matched area(s) | Notes |\n|---|---|---|\n| `services/payments/processor.go` | `payments` | matches `**/payment*/**` |\n| `pkg/auth/session_test.go` | `auth`, `tests` | matches `**/auth/**` and `**/*_test.go` |\n| `internal/retry/backoff.go` | `retry` | matches `**/backoff*` |\n| `docs/adr/0001-risk-model.md` | `docs` | matches `**/*.md` and `**/docs/**` |\n| `scripts/release.sh` | `unclassified` | no rule covers `.sh` files |\n\nA file like `pkg/auth/session_test.go` appears in both `auth` (priority 20)\nand `tests` (priority 70). Because areas are sorted by priority, `auth` always\nprecedes `tests` in the output.\n\n## Example output\n\n**Text:**\n```\n$ pushbadger analyze --base main\n\nRisk analysis: main...HEAD\n\npayments (1 file)\n  internal/payments/checkout.go\n\nauth (2 files)\n  internal/auth/login.go\n  internal/auth/session.go\n\ndb (1 file)\n  db/migrations/0001_add_users.sql\n\nunclassified (1 file)\n  cmd/app/main.go\n\n5 files, 4 areas\n```\n\n**JSON (`--format json`):**\n```json\n{\n  \"base\": \"main\",\n  \"head\": \"HEAD\",\n  \"mode\": \"diff\",\n  \"ruleset_version\": 1,\n  \"files\": [\n    { \"path\": \"cmd/app/main.go\" },\n    { \"path\": \"db/migrations/0001_add_users.sql\" },\n    { \"path\": \"internal/auth/login.go\" },\n    { \"path\": \"internal/auth/session.go\" },\n    { \"path\": \"internal/payments/checkout.go\" }\n  ],\n  \"areas\": [\n    {\n      \"name\": \"payments\",\n      \"priority\": 10,\n      \"files\": [{ \"path\": \"internal/payments/checkout.go\" }]\n    },\n    {\n      \"name\": \"auth\",\n      \"priority\": 20,\n      \"files\": [\n        { \"path\": \"internal/auth/login.go\" },\n        { \"path\": \"internal/auth/session.go\" }\n      ]\n    },\n    {\n      \"name\": \"db\",\n      \"priority\": 30,\n      \"files\": [{ \"path\": \"db/migrations/0001_add_users.sql\" }]\n    },\n    {\n      \"name\": \"unclassified\",\n      \"priority\": 9223372036854775807,\n      \"files\": [{ \"path\": \"cmd/app/main.go\" }]\n    }\n  ]\n}\n```\n\n**Staged changes:**\n```\n$ pushbadger analyze --staged\n\nRisk analysis: staged changes (HEAD → index)\n\nauth (1 file)\n  internal/auth/newfeature.go\n\n1 file, 1 area\n```\n\n## Version\n\n`--version` reports both the app version and the active ruleset version:\n\n```\n$ pushbadger --version\npushbadger v0.1.0-alpha (ruleset version 1)\n```\n\nThe `ruleset_version` field is also included in every JSON report, so consumers\ncan detect when reports are produced with different rulesets.\n\n## Ruleset format\n\nThe default embedded ruleset covers eight areas. Override at runtime with\n`--rules path/to/rules.yaml`:\n\n```yaml\nversion: 1\nrules:\n  - area: payments\n    priority: 10\n    patterns:\n      - \"**/payment*/**\"\n      - \"**/billing/**\"\n\n  - area: auth\n    priority: 20\n    patterns:\n      - \"**/auth/**\"\n      - \"**/session*\"\n```\n\n**Schema:**\n- `version` — integer; propagated to `ruleset_version` in JSON reports and `--version` output\n- `rules[].area` — name of the risk area\n- `rules[].priority` — lower number = higher priority; controls sort order in output\n- `rules[].patterns` — [doublestar](https://github.com/bmatcuk/doublestar) glob patterns matched against the lowercased file path\n\n## Limits and truncation\n\n- Max **200 files** per report\n- Max **200 KB** raw diff output\n- If either limit is exceeded, `truncated: true` is set in the JSON report, a\n  `truncation_reason` object is added naming which limit was hit, and a warning\n  is written to stderr\n\n```json\n\"truncated\": true,\n\"truncation_reason\": {\n  \"reason\": \"diff_size\",\n  \"max_files\": 200,\n  \"max_diff_size_kb\": 200\n}\n```\n\n`reason` is one of `\"files\"`, `\"diff_size\"`, or `\"files_and_diff_size\"`.\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| 0 | Success |\n| 2 | Usage error or git error (not in a repo, bad flags, etc.) |\n| 3 | Internal failure |\n\n## Determinism\n\nSame diff + same ruleset version = byte-identical output (text and JSON). No\ntimestamps are included in output.\n\n**What is deterministic:**\n- File lists within each area are sorted by path.\n- Areas are sorted by priority (ascending), then name for ties.\n- `unclassified` is always last.\n- The `ruleset_version` field lets consumers detect ruleset changes between runs.\n\nThe integration test suite (`test/integration/`) creates a real temporary git\nrepository on every run and verifies these properties end-to-end:\n\n- The same fixture diff produces byte-identical JSON across five consecutive runs.\n- A file that matches multiple areas always appears in those areas in the same\n  priority order across repeated runs.\n- Files with no matching rule always land in `unclassified`, which is always last.\n- Every JSON report includes a `ruleset_version` field.\n\nRun the full suite:\n\n```sh\ngo test ./...\n# or\nmake test\n```\n\nRun only integration tests:\n\n```sh\ngo test ./test/integration/\n```\n\n## Development\n\n```sh\nmake build   # compile to ./pushbadger\nmake test    # go test ./...\nmake lint    # go vet ./...\nmake clean   # remove ./pushbadger binary\n```\n\n## Self-referential smoke test\n\nRunning PushBadger on its own repository is a good sanity check and doubles as\na canonical determinism fixture (same commit range + same ruleset = same output):\n\n```\n$ pushbadger analyze --base $(git rev-list --max-parents=0 HEAD) --head HEAD\n\nRisk analysis: \u003cinitial-sha\u003e...HEAD\n\nconfig (2 files)\n  config/embed.go\n  config/risk_rules.yaml\n\ntests (2 files)\n  internal/analyzer/heuristics_test.go\n  test/integration/analyze_test.go\n\ndocs (2 files)\n  CHANGELOG.md\n  README.md\n\nunclassified (10 files)\n  LICENSE\n  cmd/pushbadger/main.go\n  go.mod\n  go.sum\n  internal/analyzer/heuristics.go\n  ...\n```\n\n(Exact file counts grow as the repo does; area assignments and sort order are stable.)\n\n## Acknowledgments\n\nBuilt with assistance from [Claude Code](https://claude.ai/claude-code),\nAnthropic's AI coding assistant.\n\nCopyright 2026 Adam Deane\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadmbahm%2Fpushbadger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadmbahm%2Fpushbadger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadmbahm%2Fpushbadger/lists"}