feat(sync): auto-push after merge with safety check (bd-7ch)

Add auto-push functionality to PullFromSyncBranch for true one-command sync:
- After successful content merge, auto-push to remote by default
- Safety check: warn (but dont block) if >50% issues vanished AND >5 existed
- Vanished = removed from JSONL entirely, NOT status=closed

Changes:
- Add push parameter to PullFromSyncBranch function
- Add Pushed field to PullResult struct
- Add countIssuesInContent helper for safety check
- Add test for countIssuesInContent function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-02 20:57:53 -08:00
parent 7f13623683
commit c93b755344
3 changed files with 105 additions and 2 deletions

View File

@@ -458,3 +458,52 @@ func writeFile(t *testing.T, path, content string) {
t.Fatalf("Failed to write file %s: %v", path, err)
}
}
// TestCountIssuesInContent tests the issue counting helper function (bd-7ch)
func TestCountIssuesInContent(t *testing.T) {
tests := []struct {
name string
content []byte
want int
}{
{
name: "empty content",
content: []byte{},
want: 0,
},
{
name: "nil content",
content: nil,
want: 0,
},
{
name: "single issue",
content: []byte(`{"id":"test-1"}`),
want: 1,
},
{
name: "multiple issues",
content: []byte(`{"id":"test-1"}` + "\n" + `{"id":"test-2"}` + "\n" + `{"id":"test-3"}`),
want: 3,
},
{
name: "trailing newline",
content: []byte(`{"id":"test-1"}` + "\n" + `{"id":"test-2"}` + "\n"),
want: 2,
},
{
name: "empty lines ignored",
content: []byte(`{"id":"test-1"}` + "\n" + "\n" + `{"id":"test-2"}` + "\n" + " " + "\n"),
want: 2,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := countIssuesInContent(tt.content)
if got != tt.want {
t.Errorf("countIssuesInContent() = %d, want %d", got, tt.want)
}
})
}
}