test(server): cover tag-mode version pill; chore: rename gitArchive ref param; docs: prefix slash note
c0a9f6bafe8579ff8e2ba44427919c96906a09a2
humdrum <me@humdrum.me> · 2026-06-19 12:43
parent 6e079577
test(server): cover tag-mode version pill; chore: rename gitArchive ref param; docs: prefix slash note Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
3 files changed
docs/JUJUTSU.md +1 −0
@@ -61,6 +61,7 @@ enabled: true
package: "." # or ./cmd/<name>
source: bookmark # opt in to bookmark-mode releases
# bookmark_prefix: release/ # default; change only if you need a different prefix
+ # must end in "/" so the version is its own path segment
```
Register the release webhook (same command as tag mode; see [MANUAL.md](MANUAL.md) for webhook
internal/release/release.go +3 −3
@@ -166,17 +166,17 @@ }
return ver, nil
}
-func gitArchive(bareRepo, prefix, tag, outPath string) error {
+func gitArchive(bareRepo, prefix, ref, outPath string) error {
out, err := os.Create(outPath)
if err != nil {
return err
}
defer out.Close()
- cmd := exec.Command("git", "-C", bareRepo, "archive", "--format=tar.gz", "--prefix="+prefix+"/", tag)
+ cmd := exec.Command("git", "-C", bareRepo, "archive", "--format=tar.gz", "--prefix="+prefix+"/", ref)
cmd.Stdout = out
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
- return fmt.Errorf("git archive %s@%s: %w", bareRepo, tag, err)
+ return fmt.Errorf("git archive %s@%s: %w", bareRepo, ref, err)
}
return nil
}
internal/server/display_test.go +26 −0
@@ -51,3 +51,29 @@ if ref.Message != "ship v1.2.3" {
t.Errorf("label = %q, want tip subject", ref.Message)
}
}
+
+// tagRepo builds a bare "proj.git" in tag mode (no .custard.yaml) with a
+// lightweight semver tag v1.0.0 on a commit.
+func tagRepo(t *testing.T) *Server {
+ t.Helper()
+ root := t.TempDir()
+ work := filepath.Join(root, "work")
+ gitRun(t, root, "init", "-q", "-b", "main", "work")
+ if err := os.WriteFile(filepath.Join(work, "README.md"),
+ []byte("hello\n"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ gitRun(t, work, "add", ".")
+ gitRun(t, work, "commit", "-q", "-m", "init")
+ gitRun(t, work, "tag", "v1.0.0")
+ gitRun(t, work, "clone", "-q", "--bare", work, filepath.Join(root, "proj.git"))
+ return &Server{store: gitread.New(root), cfg: config.Config{ReposPath: root}}
+}
+
+func TestLatestReleaseTagMode(t *testing.T) {
+ s := tagRepo(t)
+ ref, ok := s.latestRelease("proj")
+ if !ok || ref.Name != "v1.0.0" {
+ t.Fatalf("latestRelease = %q,%v; want v1.0.0,true", ref.Name, ok)
+ }
+}