@@ -17,6 +17,14 @@ import (
1717
1818// https://github.com/go-git/go-git/issues/296
1919
20+ func CommitTime (commit * goGitPlumbingObject.Commit ) time.Time {
21+ if commit .Committer .When .After (commit .Author .When ) {
22+ return commit .Committer .When
23+ } else {
24+ return commit .Author .When
25+ }
26+ }
27+
2028func CommitHash (repo * goGit.Repository , commit string ) (fs.FS , error ) {
2129 gitCommit , err := repo .CommitObject (goGitPlumbing .NewHash (commit ))
2230 if err != nil {
@@ -31,6 +39,7 @@ func CommitHash(repo *goGit.Repository, commit string) (fs.FS, error) {
3139 storer : repo .Storer ,
3240 tree : tree ,
3341 name : "." ,
42+ Mod : CommitTime (gitCommit ),
3443 },
3544 }, nil
3645}
@@ -49,6 +58,8 @@ type gitFS struct {
4958 tree * goGitPlumbingObject.Tree
5059 entry * goGitPlumbingObject.TreeEntry // might be nil ("." at the top-level of the repo)
5160
61+ Mod time.Time
62+
5263 // cached values
5364 name string // full path from the repository root
5465 size int64 // Tree.Size value for non-directories (more efficient than opening/reading the blob)
@@ -342,7 +353,7 @@ func (f gitFS) Mode() fs.FileMode {
342353
343354// https://pkg.go.dev/io/fs#FileInfo: modification time
344355func (f gitFS ) ModTime () time.Time {
345- return time. Time {} // TODO maybe pass down whichever is more recent of commit.Author.When vs commit.Committer.When ?
356+ return f . Mod
346357}
347358
348359// https://pkg.go.dev/io/fs#FileInfo: abbreviation for Mode().IsDir()
0 commit comments