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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user