Skip to content

feat: Safe Git Operations Interface (GitOps) - #40

Merged
RevCBH merged 22 commits into
mainfrom
RevCBH/safe-git-ops-spec
Jan 22, 2026
Merged

feat: Safe Git Operations Interface (GitOps)#40
RevCBH merged 22 commits into
mainfrom
RevCBH/safe-git-ops-spec

Conversation

@RevCBH

@RevCBH RevCBH commented Jan 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Introduces a new GitOps interface that provides safe, validated git operations bound to specific repository paths
  • Adds MockGitOps for testing with assertion helpers and safety simulation
  • Migrates the worker package to use GitOps instead of raw git.Runner calls

Problem

The previous pattern of passing directory paths directly to git.Runner.Exec() was error-prone:

  • Empty dir string would silently run commands in the current working directory
  • A production bug caused tests to inadvertently run destructive git commands (git checkout ., git reset, git clean -fd) on the actual repository instead of test directories
  • No type safety to prevent passing the wrong path

Solution

The new GitOps interface:

  • Path binding: Each instance is bound to a specific repository path at construction time
  • Validation: Path is validated to be non-empty and to exist before any operation
  • Per-repo locking: Write operations acquire locks to prevent concurrent modifications
  • Rich result types: Structured return values (e.g., StatusResult, MergeResult) instead of raw strings
  • Mock support: MockGitOps enables precise test control with safety simulation and assertion helpers

Test plan

  • Unit tests for GitOps implementation covering all operations
  • Unit tests for MockGitOps assertion helpers
  • Integration tests for git operations in real repositories
  • Worker tests migrated to use MockGitOps
  • CI passes

🤖 Generated with Claude Code

RevCBH and others added 22 commits January 21, 2026 23:21
- Fix markdown code block formatting in spec.md skill
- Improve path comparison in NewGitOps using filepath.Clean for toplevel
- Use filepath.Rel for worktree base validation instead of string prefix
- Add remote URL validation to validateBranchGuard
- Pass remote parameter to branch guard for Push operations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@RevCBH
RevCBH merged commit 40c6a42 into main Jan 22, 2026
2 checks passed
@RevCBH
RevCBH deleted the RevCBH/safe-git-ops-spec branch January 22, 2026 14:26
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