fix(dev): shallow clone pull requests

This commit is contained in:
Thomas Camlong committed 2026-08-01 23:35:08 +02:00
1 parent c8c5dbc506
commit 934b6e69f4
2 files changed
+13 -1

No files matched your search

+5 -1
View File
@@ -41,7 +41,7 @@ func buildPRImage(ctx context.Context, number int, tag string, stdout, stderr io
defer os.RemoveAll(temporaryRoot)
checkout := filepath.Join(temporaryRoot, "homarr")
clone := exec.CommandContext(ctx, "gh", "repo", "clone", gh.Repo, checkout, "--", "--filter=blob:none")
clone := exec.CommandContext(ctx, "gh", prCloneArgs(checkout)...)
clone.Stdout = stdout
clone.Stderr = stderr
if err := clone.Run(); err != nil {
@@ -67,6 +67,10 @@ func buildPRImage(ctx context.Context, number int, tag string, stdout, stderr io
}, stdout, stderr)
}
func prCloneArgs(checkout string) []string {
return []string{"repo", "clone", gh.Repo, checkout, "--", "--depth=1", "--filter=blob:none"}
}
func RebuildImage(image docker.Image) error {
return RebuildImageContext(context.Background(), image, os.Stdout, os.Stderr)
}
@@ -2,6 +2,7 @@ package run
import (
"os"
"slices"
"strconv"
"testing"
@@ -18,6 +19,13 @@ func TestPRPlanUsesAMD64(t *testing.T) {
}
}
func TestPRCloneIsShallow(t *testing.T) {
args := prCloneArgs("/tmp/checkout")
if !slices.Contains(args, "--depth=1") || !slices.Contains(args, "--filter=blob:none") {
t.Fatalf("clone args = %v", args)
}
}
func TestBuildPlanFailsWhenNoPortIsAvailable(t *testing.T) {
_, err := BuildPlan(Options{Tag: "dev", FindPort: func(int) int { return 0 }})
if err == nil {