From afc044753d21eb4a0bfe10f3249a114ad67862fe Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Thu, 20 Aug 2026 17:45:35 +0900 Subject: [PATCH] knotmirror: return committer date on `git.getTree` Signed-off-by: Seongmin Lee --- knotmirror/xrpc/git_get_tree.go | 18 ++++++++++++++++-- knotserver/git/last_commit.go | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/knotmirror/xrpc/git_get_tree.go b/knotmirror/xrpc/git_get_tree.go index 1b418db7..c12b6f3b 100644 --- a/knotmirror/xrpc/git_get_tree.go +++ b/knotmirror/xrpc/git_get_tree.go @@ -106,6 +106,7 @@ func (x *Xrpc) getTree(ctx context.Context, repo syntax.DID, ref, treePath strin } if len(unHitPaths) > 0 { + unHitPaths = withTreePathEntry(unHitPaths) commits, err := gitea.WalkGitLog(ctx, repoPath, headRef, treePath, unHitPaths...) if err != nil { return nil, nil, err @@ -154,6 +155,9 @@ func (x *Xrpc) getTree(ctx context.Context, repo syntax.DID, ref, treePath strin return nil, nil, fmt.Errorf("unexpected type: %s for commit id: %s", typ, commitId) } c, err := gitea.ReadCommit(plumbing.NewHash(commitId), io.LimitReader(batchReader, size)) + if err != nil { + return nil, nil, fmt.Errorf("read commit %s: %w", commitId, err) + } if _, err := batchReader.Discard(1); err != nil { return nil, nil, err } @@ -185,10 +189,11 @@ func (x *Xrpc) getTree(ctx context.Context, repo syntax.DID, ref, treePath strin entryLastCommit = &tangled.GitTempGetTree_LastCommit{ Hash: commit.Hash.String(), Message: commit.Message, - When: commit.Author.When.Format(time.RFC3339), + When: commit.Committer.When.Format(time.RFC3339), Author: &tangled.GitTempGetTree_Signature{ Email: commit.Author.Email, Name: commit.Author.Name, + When: commit.Author.When.Format(time.RFC3339), }, } } @@ -214,10 +219,11 @@ func (x *Xrpc) getTree(ctx context.Context, repo syntax.DID, ref, treePath strin outLastCommit = &tangled.GitTempGetTree_LastCommit{ Hash: lastCommit.Hash.String(), Message: lastCommit.Message, - When: lastCommit.Author.When.Format(time.RFC3339), + When: lastCommit.Committer.When.Format(time.RFC3339), Author: &tangled.GitTempGetTree_Signature{ Email: lastCommit.Author.Email, Name: lastCommit.Author.Name, + When: lastCommit.Author.When.Format(time.RFC3339), }, } } @@ -264,3 +270,11 @@ func (x *Xrpc) readme(ctx context.Context, repoPath string, entries []object.Tre } return "", "" } + +// ensure first entry is "" +func withTreePathEntry(paths []string) []string { + if len(paths) > 0 && paths[0] == "" { + return paths + } + return append([]string{""}, paths...) +} diff --git a/knotserver/git/last_commit.go b/knotserver/git/last_commit.go index 820e77e1..d984bbed 100644 --- a/knotserver/git/last_commit.go +++ b/knotserver/git/last_commit.go @@ -145,7 +145,7 @@ func (g *GitRepo) lastCommitDir(ctx context.Context, parent lastCommitDir) (map[ } } - output, err := g.streamingGitLog(ctx, "--pretty=format:%H,%ad,%s", "--date=unix", "--name-only", "--", pathSpec) + output, err := g.streamingGitLog(ctx, "--pretty=format:%H,%cd,%s", "--date=unix", "--name-only", "--", pathSpec) if err != nil { return nil, err } -- 2.51.2