Commit 4fdd561
Eric Bower
·
2026-08-09 11:14:57 -0400 EDT
parent 8759922
chore: ignore .jj during workspace copy
2 files changed,
+50,
-2
M
main.go
M
main.go
+2,
-2
1@@ -447,9 +447,9 @@ func (w *WorkspaceRsync) Setup() error {
2 w.Cfg.KeyLocation,
3 w.Cfg.CertificateLocation,
4 )
5- cmd = exec.Command("rsync", "-e", sshcmd, "-rv", `--exclude="/.git"`, w.Source+"/", w.Dest+"/")
6+ cmd = exec.Command("rsync", "-e", sshcmd, "-rv", "--exclude=/.git", "--exclude=/.jj", w.Source+"/", w.Dest+"/")
7 } else {
8- cmd = exec.Command("rsync", "-rv", `--exclude="/.git"`, w.Source+"/", w.Dest+"/")
9+ cmd = exec.Command("rsync", "-rv", "--exclude=/.git", "--exclude=/.jj", w.Source+"/", w.Dest+"/")
10 }
11 return runCmd(cmd, log)
12 }
+48,
-0
1@@ -805,3 +805,51 @@ func TestWaitAndReport_Cancellation(t *testing.T) {
2 }
3 }
4 }
5+
6+func TestWorkspaceRsync_ExcludesGitAndJJ(t *testing.T) {
7+ if _, err := exec.LookPath("rsync"); err != nil {
8+ t.Skip("rsync not found, skipping test")
9+ }
10+
11+ srcDir := t.TempDir()
12+ if err := os.WriteFile(filepath.Join(srcDir, "hello.txt"), []byte("world"), 0644); err != nil {
13+ t.Fatalf("failed to write hello.txt: %v", err)
14+ }
15+ if err := os.MkdirAll(filepath.Join(srcDir, ".git"), 0755); err != nil {
16+ t.Fatalf("failed to mkdir .git: %v", err)
17+ }
18+ if err := os.WriteFile(filepath.Join(srcDir, ".git", "HEAD"), []byte("ref: refs/heads/main"), 0644); err != nil {
19+ t.Fatalf("failed to write .git/HEAD: %v", err)
20+ }
21+ if err := os.MkdirAll(filepath.Join(srcDir, ".jj"), 0755); err != nil {
22+ t.Fatalf("failed to mkdir .jj: %v", err)
23+ }
24+ if err := os.WriteFile(filepath.Join(srcDir, ".jj", "repo"), []byte("jj data"), 0644); err != nil {
25+ t.Fatalf("failed to write .jj/repo: %v", err)
26+ }
27+
28+ wk := &WorkspaceRsync{
29+ Cfg: &Cfg{},
30+ Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
31+ Source: srcDir,
32+ }
33+ t.Cleanup(func() {
34+ _ = wk.Cleanup()
35+ })
36+
37+ if err := wk.Setup(); err != nil {
38+ t.Fatalf("WorkspaceRsync.Setup failed: %v", err)
39+ }
40+
41+ destDir := wk.GetDir()
42+ if _, err := os.Stat(filepath.Join(destDir, "hello.txt")); os.IsNotExist(err) {
43+ t.Error("expected hello.txt to exist in dest workspace")
44+ }
45+ if _, err := os.Stat(filepath.Join(destDir, ".git")); !os.IsNotExist(err) {
46+ t.Error("expected .git to be excluded from dest workspace")
47+ }
48+ if _, err := os.Stat(filepath.Join(destDir, ".jj")); !os.IsNotExist(err) {
49+ t.Error("expected .jj to be excluded from dest workspace")
50+ }
51+}
52+