cmd/sketch: add -upstream flag for git branch management
To be used in future work.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s40fdfb9a579bf6f2k
diff --git a/loop/agent.go b/loop/agent.go
index fd01f33..466cec0 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -320,6 +320,7 @@
mu sync.Mutex // protects following
lastHEAD string // hash of the last HEAD that was pushed to the host
gitRemoteAddr string // HTTP URL of the host git repo
+ upstream string // upstream branch for git work
seenCommits map[string]bool // Track git commits we've already seen (by hash)
branchName string
}
@@ -336,6 +337,12 @@
return ags.branchName
}
+func (ags *AgentGitState) Upstream() string {
+ ags.mu.Lock()
+ defer ags.mu.Unlock()
+ return ags.upstream
+}
+
type Agent struct {
convo ConvoInterface
config AgentConfig // config for this agent
@@ -914,6 +921,11 @@
return a.originalBudget
}
+// Upstream returns the upstream branch for git work
+func (a *Agent) Upstream() string {
+ return a.gitState.Upstream()
+}
+
// AgentConfig contains configuration for creating a new Agent.
type AgentConfig struct {
Context context.Context
@@ -936,6 +948,8 @@
OutsideHTTP string
// Outtie's Git server
GitRemoteAddr string
+ // Upstream branch for git work
+ Upstream string
// Commit to checkout from Outtie
Commit string
// Prefix for git branches created by sketch
@@ -960,6 +974,7 @@
gitState: AgentGitState{
seenCommits: make(map[string]bool),
gitRemoteAddr: config.GitRemoteAddr,
+ upstream: config.Upstream,
},
outsideHostname: config.OutsideHostname,
outsideOS: config.OutsideOS,