Remove 10,955 lines of dead code from the JSONL sync-branch pipeline, now replaced by native Dolt push/pull via git remotes. Deleted: - internal/syncbranch/ (5,720 lines: worktree management, integrity checks) - cmd/bd/deletion_tracking.go (3-way JSONL merge) - cmd/bd/snapshot_manager.go (JSONL snapshot tracking) - cmd/bd/doctor/sync_branch_jsonl.go (JSONL validation) - cmd/bd/doctor/fix/sync_branch.go (sync branch repair) - All associated test files Preserved: - bd export / bd import (manual tools) - isGitRepo(), gitHasUpstream() (still have callers) - Doctor check stubs (return StatusOK N/A) Added: - BootstrapFromGitRemote() for Dolt-in-Git bootstrap - Dolt push in bd sync via store.Push() - sync.git-remote config key - HasRemote() on DoltStore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Executed-By: beads/crew/emma Rig: beads Role: crew
60 lines
1.9 KiB
Go
60 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
|
|
"github.com/steveyegge/beads/internal/beads"
|
|
)
|
|
|
|
// isGitRepo checks if the current working directory is in a git repository.
|
|
// NOTE: This intentionally checks CWD, not the beads repo. It's used as a guard
|
|
// before calling other git functions to prevent hangs on Windows (GH#727).
|
|
// Does not use RepoContext because it's a prerequisite check for git availability.
|
|
func isGitRepo() bool {
|
|
cmd := exec.Command("git", "rev-parse", "--git-dir")
|
|
return cmd.Run() == nil
|
|
}
|
|
|
|
// gitHasUpstream checks if the current branch has an upstream configured in the beads repository.
|
|
// Uses RepoContext to ensure git commands run in the correct repository.
|
|
// Uses git config directly for compatibility with Git for Windows.
|
|
func gitHasUpstream() bool {
|
|
rc, err := beads.GetRepoContext()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
ctx := context.Background()
|
|
// Get current branch name
|
|
branchCmd := rc.GitCmd(ctx, "symbolic-ref", "--short", "HEAD")
|
|
branchOutput, err := branchCmd.Output()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
branch := strings.TrimSpace(string(branchOutput))
|
|
|
|
return gitBranchHasUpstream(branch)
|
|
}
|
|
|
|
// gitBranchHasUpstream checks if a specific branch has an upstream configured.
|
|
// Unlike gitHasUpstream(), this works even when HEAD is detached (e.g., jj/jujutsu).
|
|
// Uses RepoContext to ensure git commands run in the correct repository.
|
|
func gitBranchHasUpstream(branch string) bool {
|
|
rc, err := beads.GetRepoContext()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
|
|
ctx := context.Background()
|
|
// Check if remote and merge refs are configured for the branch
|
|
remoteCmd := rc.GitCmd(ctx, "config", "--get", fmt.Sprintf("branch.%s.remote", branch)) //nolint:gosec // G204: branch from caller
|
|
mergeCmd := rc.GitCmd(ctx, "config", "--get", fmt.Sprintf("branch.%s.merge", branch)) //nolint:gosec // G204: branch from caller
|
|
|
|
remoteErr := remoteCmd.Run()
|
|
mergeErr := mergeCmd.Run()
|
|
|
|
return remoteErr == nil && mergeErr == nil
|
|
}
|