Support local-only git repos without remote origin (bd-biwp)

- Add hasGitRemote() helper to detect if any remote exists
- Gracefully skip git pull/push when no remote configured
- Daemon now works in local-only mode (RPC, auto-flush, JSONL export)
- Add comprehensive test coverage for local-only workflows
- Fixes GH#279: daemon crash on repos without origin remote

Amp-Thread-ID: https://ampcode.com/threads/T-5dad0ca8-ac77-4ae0-8de6-208b23ea47af
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Steve Yegge
2025-11-09 16:16:45 -08:00
parent 23fce6ea49
commit 4de9f015d6
4 changed files with 166 additions and 0 deletions

View File

@@ -16,6 +16,11 @@ import (
// syncBranchCommitAndPush commits JSONL to the sync branch using a worktree
// Returns true if changes were committed, false if no changes or sync.branch not configured
func syncBranchCommitAndPush(ctx context.Context, store storage.Storage, autoPush bool, log daemonLogger) (bool, error) {
// Check if any remote exists (bd-biwp: support local-only repos)
if !hasGitRemote(ctx) {
return true, nil // Skip sync branch commit/push in local-only mode
}
// Get sync.branch config
syncBranch, err := store.GetConfig(ctx, "sync.branch")
if err != nil {
@@ -169,6 +174,11 @@ func gitPushFromWorktree(ctx context.Context, worktreePath, branch string) error
// syncBranchPull pulls changes from the sync branch into the worktree
// Returns true if pull was performed, false if sync.branch not configured
func syncBranchPull(ctx context.Context, store storage.Storage, log daemonLogger) (bool, error) {
// Check if any remote exists (bd-biwp: support local-only repos)
if !hasGitRemote(ctx) {
return true, nil // Skip sync branch pull in local-only mode
}
// Get sync.branch config
syncBranch, err := store.GetConfig(ctx, "sync.branch")
if err != nil {