Skip to content

feat(git): implement git audit module#6

Merged
kaustuvbot merged 10 commits into
mainfrom
feat/git-module
Feb 22, 2026
Merged

feat(git): implement git audit module#6
kaustuvbot merged 10 commits into
mainfrom
feat/git-module

Conversation

@kaustuvbot
Copy link
Copy Markdown
Owner

Summary

Implements the complete git audit module for devopsctl.

  • Git client foundation (internal/git/client.go): lightweight wrapper for executing git commands safely
  • Repository size check (internal/git/size.go): detects repos exceeding configured size thresholds
  • Stale branch detection (internal/git/branches.go): flags branches with no recent commits
  • Large file scanner (internal/git/files.go): identifies files exceeding size limits
  • Git runner (internal/git/runner.go): orchestrates all git checks and returns []CheckResult
  • CLI wiring (internal/cli/audit.go): devopsctl audit git command wired to runner
  • Unit tests (internal/git/*_test.go): coverage for size check, stale branch detection, large file scanner, runner, and error handling

Test plan

  • go build ./... passes
  • go test ./... passes (all git package tests green)
  • go vet ./... produces no warnings
  • devopsctl audit git command runs without error

🤖 Generated with Claude Code

kaustuvbot and others added 10 commits February 22, 2026 10:21
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements git command executor wrapper using os/exec with timeout
support, helper methods for branch listing, commit dates, and repo
statistics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add CheckRepoSize() using git count-objects -vH to detect repos
exceeding size threshold (default 500MB). Returns MEDIUM severity
finding if threshold exceeded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add CheckStaleBranches() to list all branches and detect those not
updated in configured days (default 90). Returns LOW severity finding
for each stale branch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add CheckLargeFiles() to scan tracked files and detect those exceeding
size threshold (default 50MB). Returns MEDIUM severity finding for each
large file found.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add unit tests for convertToMB function covering all size units
(B, KB, MB, GB, TB, MiB, GiB) and threshold comparison logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add unit tests for branch age calculation, name parsing, threshold
comparison, file size parsing, and regex pattern matching.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add Runner struct with RunAll() method that orchestrates all three
git checks: repo-size, stale-branches, large-files. Follows AWS
runner pattern with closure-based check list and error aggregation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implement audit git command with --repo flag. Uses git runner to
execute checks for repo size, stale branches, and large files.
Follows same pattern as AWS and Docker audit commands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add unit tests for runner execution, results aggregation, and severity
level validation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kaustuvbot kaustuvbot merged commit bdc90a4 into main Feb 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant