Add initial-commit CLI flag for specifying git reference
This adds a new -initial-commit flag to the sketch CLI which allows specifying
a different git reference besides HEAD as the starting point. The flag is
incompatible with -unsafe mode and will show an error if both are used.
Co-Authored-By: sketch <hello@sketch.dev>
diff --git a/dockerimg/dockerimg.go b/dockerimg/dockerimg.go
index 3a0cc7e..a6be67b 100644
--- a/dockerimg/dockerimg.go
+++ b/dockerimg/dockerimg.go
@@ -82,6 +82,9 @@
// Initial prompt
Prompt string
+
+ // Initial commit to use as starting point
+ InitialCommit string
}
// LaunchContainer creates a docker container for a project, installs sketch and opens a connection to it.
@@ -157,8 +160,8 @@
// Get the current host git commit
var commit string
- if out, err := combinedOutput(ctx, "git", "rev-parse", "HEAD"); err != nil {
- return fmt.Errorf("git rev-parse HEAD: %w", err)
+ if out, err := combinedOutput(ctx, "git", "rev-parse", config.InitialCommit); err != nil {
+ return fmt.Errorf("git rev-parse %s: %w", config.InitialCommit, err)
} else {
commit = strings.TrimSpace(string(out))
}