This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

knotmirror/xrpc/gitea: resolve annotated tags to commits, not tags

Signed-off-by: dawn <dawn@tangled.org>

author
dawn
date (Jul 27, 2026, 2:45 PM +0300) commit 3da81cf8 parent 4ce2be78 change-id mxtwxruo
+30 -1
+1 -1
knotmirror/xrpc/gitea/batch.go
··· 25 25 wr, rd, cancel := CatFileBatch(ctx, repoPath) 26 26 defer cancel() 27 27 28 - if _, err := wr.Write([]byte(rev + "\n")); err != nil { 28 + if _, err := wr.Write([]byte(rev + "^{commit}\n")); err != nil { 29 29 return nil, fmt.Errorf("write rev: %w", err) 30 30 } 31 31 sha, typ, size, err := ReadBatchLine(rd)
+29
knotmirror/xrpc/gitea/commit_test.go
··· 4 4 package gitea 5 5 6 6 import ( 7 + "context" 8 + "os" 9 + "os/exec" 10 + "path/filepath" 7 11 "strings" 8 12 "testing" 9 13 ··· 12 16 "github.com/stretchr/testify/require" 13 17 "tangled.org/core/types" 14 18 ) 19 + 20 + func TestGetCommitDereferencesAnnotatedTag(t *testing.T) { 21 + repo := t.TempDir() 22 + runGit := func(args ...string) []byte { 23 + t.Helper() 24 + cmd := exec.Command("git", args...) 25 + cmd.Dir = repo 26 + out, err := cmd.CombinedOutput() 27 + require.NoError(t, err, string(out)) 28 + return out 29 + } 30 + 31 + runGit("init") 32 + runGit("config", "user.name", "test") 33 + runGit("config", "user.email", "test@example.com") 34 + require.NoError(t, os.WriteFile(filepath.Join(repo, "file.txt"), []byte("hello\n"), 0o644)) 35 + runGit("add", "file.txt") 36 + runGit("commit", "-m", "initial") 37 + runGit("tag", "-a", "v0.1.0", "-m", "release") 38 + 39 + want := strings.TrimSpace(string(runGit("rev-parse", "v0.1.0^{commit}"))) 40 + commit, err := GetCommit(context.Background(), repo, "v0.1.0") 41 + require.NoError(t, err) 42 + assert.Equal(t, want, commit.Hash.String()) 43 + } 15 44 16 45 func TestCommitFromReader(t *testing.T) { 17 46 commitString := `tree f1a6cb52b2d16773290cefe49ad0684b50a4f930