feat(gitsync): auto-bootstrap tom wiki från remote live-gren

Ett repo utan commits adopterar origin/<live_branch> automatiskt vid
första bakgrundssynken — färsk instans behöver ingen manuell reset.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-02 23:19:48 +02:00
parent e181e8e68e
commit 19cf285d80
2 changed files with 32 additions and 0 deletions

View File

@@ -170,6 +170,24 @@ func (r *Repo) Push(branch string) error {
return err
}
// HasCommits reports whether the repository has any commit (false on
// a freshly initialised, unborn branch).
func (r *Repo) HasCommits() bool {
r.mu.Lock()
defer r.mu.Unlock()
_, err := r.run("rev-parse", "--verify", "HEAD")
return err == nil
}
// RemoteBranchExists reports whether origin/branch is known locally
// (run Fetch first for a fresh answer).
func (r *Repo) RemoteBranchExists(branch string) bool {
r.mu.Lock()
defer r.mu.Unlock()
_, err := r.run("rev-parse", "--verify", "refs/remotes/origin/"+branch)
return err == nil
}
// MergeInProgress reports whether a merge has been started but not
// yet committed or aborted.
func (r *Repo) MergeInProgress() bool {