sketch: add fetch-on-launch flag for git fetch on startup
Defaults to true, i.e. no changes.
But now I can turn it off so that running Sketch
doesn't pop 1password asking for ssh keys.
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s494a69769c279ad8k
diff --git a/loop/agent.go b/loop/agent.go
index 872f77f..da0f847 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -1130,6 +1130,8 @@
BashTimeouts *claudetool.Timeouts
// PassthroughUpstream configures upstream remote for passthrough to innie
PassthroughUpstream bool
+ // FetchOnLaunch enables git fetch during initialization
+ FetchOnLaunch bool
}
// NewAgent creates a new Agent.
@@ -1242,15 +1244,16 @@
// If a commit was specified, we fetch and reset to it.
if a.config.Commit != "" && a.gitState.gitRemoteAddr != "" {
- slog.InfoContext(ctx, "updating git repo", "commit", a.config.Commit)
-
- cmd := exec.CommandContext(ctx, "git", "fetch", "--prune", "origin")
- cmd.Dir = a.workingDir
- if out, err := cmd.CombinedOutput(); err != nil {
- return fmt.Errorf("git fetch: %s: %w", out, err)
+ if a.config.FetchOnLaunch {
+ slog.InfoContext(ctx, "updating git repo", "commit", a.config.Commit)
+ cmd := exec.CommandContext(ctx, "git", "fetch", "--prune", "origin")
+ cmd.Dir = a.workingDir
+ if out, err := cmd.CombinedOutput(); err != nil {
+ return fmt.Errorf("git fetch: %s: %w", out, err)
+ }
}
// The -B resets the branch if it already exists (or creates it if it doesn't)
- cmd = exec.CommandContext(ctx, "git", "checkout", "-f", "-B", "sketch-wip", a.config.Commit)
+ cmd := exec.CommandContext(ctx, "git", "checkout", "-f", "-B", "sketch-wip", a.config.Commit)
cmd.Dir = a.workingDir
if checkoutOut, err := cmd.CombinedOutput(); err != nil {
// Remove git hooks if they exist and retry