@@ -17,6 +17,14 @@ import (
17
17
18
18
// https://github.com/go-git/go-git/issues/296
19
19
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
+
20
28
func CommitHash (repo * goGit.Repository , commit string ) (fs.FS , error ) {
21
29
gitCommit , err := repo .CommitObject (goGitPlumbing .NewHash (commit ))
22
30
if err != nil {
@@ -31,6 +39,7 @@ func CommitHash(repo *goGit.Repository, commit string) (fs.FS, error) {
31
39
storer : repo .Storer ,
32
40
tree : tree ,
33
41
name : "." ,
42
+ Mod : CommitTime (gitCommit ),
34
43
},
35
44
}, nil
36
45
}
@@ -49,6 +58,8 @@ type gitFS struct {
49
58
tree * goGitPlumbingObject.Tree
50
59
entry * goGitPlumbingObject.TreeEntry // might be nil ("." at the top-level of the repo)
51
60
61
+ Mod time.Time
62
+
52
63
// cached values
53
64
name string // full path from the repository root
54
65
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 {
342
353
343
354
// https://pkg.go.dev/io/fs#FileInfo: modification time
344
355
func (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
346
357
}
347
358
348
359
// https://pkg.go.dev/io/fs#FileInfo: abbreviation for Mode().IsDir()
0 commit comments