This repository was archived by the owner on Apr 23, 2024. It is now read-only.
File tree 4 files changed +22
-7
lines changed
4 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ func (g *GitHandler) DownloadRepository() error {
32
32
return nil
33
33
}
34
34
35
+ func (g * GitHandler ) GetUpdatedTime () int64 {
36
+ cacheFile , _ := ioutil .ReadFile (g .getCacheFilePath ())
37
+ cacheTime , _ := strconv .Atoi (string (cacheFile ))
38
+ return int64 (cacheTime )
39
+ }
40
+
35
41
func (g * GitHandler ) IsUpToDate () bool {
36
42
// File does not exist
37
43
_ , err := os .Stat (g .getDownloadPath ())
@@ -44,9 +50,7 @@ func (g *GitHandler) IsUpToDate() bool {
44
50
}
45
51
46
52
// Check if cache is up to date (within cacheTime interval)
47
- cacheFile , _ := ioutil .ReadFile (g .getCacheFilePath ())
48
- cacheTime , _ := strconv .Atoi (string (cacheFile ))
49
- return time .Now ().Unix () <= int64 (cacheTime + g .Cfg .Git .Update .Cache .Time )
53
+ return time .Now ().Unix () <= (g .GetUpdatedTime () + int64 (g .Cfg .Git .Update .Cache .Time ))
50
54
}
51
55
52
56
func (g * GitHandler ) GetBranches () []string {
Original file line number Diff line number Diff line change @@ -41,8 +41,6 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i
41
41
github.com/jessevdk/go-flags v1.4.0 /go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI =
42
42
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY =
43
43
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd /go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM =
44
- github.com/koron/go-github-webhook v0.0.0-20150705120715-fd8c61b5db99 h1:VXfv5FnSQV1UYzBHzX0PsqdO4g+0DyydTszhx0DzB/E =
45
- github.com/koron/go-github-webhook v0.0.0-20150705120715-fd8c61b5db99 /go.mod h1:QsucCvHs4fa2IawkhLpASmQB9h9Wo8oIBt7UsACCIRg =
46
44
github.com/kr/pretty v0.1.0 /go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo =
47
45
github.com/kr/pty v1.1.1 /go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ =
48
46
github.com/kr/text v0.1.0 /go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI =
Original file line number Diff line number Diff line change 7
7
"github.com/markbates/pkger"
8
8
"github.com/saitho/static-git-file-server/rendering"
9
9
"net/http"
10
+ "time"
10
11
11
12
"github.com/saitho/static-git-file-server/config"
12
13
"github.com/saitho/static-git-file-server/git"
@@ -74,6 +75,7 @@ func main() {
74
75
ShowTags bool
75
76
Branches []string
76
77
Tags []git.GitTag
78
+ LastUpdate time.Time
77
79
}
78
80
79
81
content , err := rendering .RenderTemplate ("/tmpl/index.html" , IndexTmplParams {
@@ -82,6 +84,7 @@ func main() {
82
84
ShowTags : cfg .Display .Index .ShowTags ,
83
85
Branches : gitHandler .GetBranches (),
84
86
Tags : gitHandler .GetTags (),
87
+ LastUpdate : time .Unix (gitHandler .GetUpdatedTime (), 0 ),
85
88
})
86
89
if err != nil {
87
90
resp .Text (http .StatusInternalServerError , err .Error ())
Original file line number Diff line number Diff line change 1
- < h1 > Git Repo</ h1 >
2
- < h2 > Git Remote: {{ .Cfg.Git.Url }}</ h2 >
1
+ < header >
2
+ < h1 > Git Repo</ h1 >
3
+ < h2 > Git Remote: {{ .Cfg.Git.Url }}</ h2 >
4
+ < h3 > Last Update: {{ .LastUpdate }}</ h3 >
5
+ </ header >
3
6
7
+ < main >
4
8
{{ if .ShowBranches }}
5
9
< h2 > Branches</ h2 >
6
10
{{ range $value := .Branches }}< a href ="/branch/{{ . }} "> {{ . }}< br > </ a > {{ end }}
@@ -12,3 +16,9 @@ <h2>Tags</h2>
12
16
< a href ="/tag/{{ .Tag }} "> {{ .Tag }} {{ if $.Cfg.Display.Tags.ShowDate }}({{ .Date }}){{ end }}< br /> </ a >
13
17
{{ end }}
14
18
{{ end }}
19
+ </ main >
20
+
21
+ < footer >
22
+ < hr />
23
+ Powered by < a href ="https://github.com/saitho/git-file-webserver " target ="_blank "> Git File Webserver</ a >
24
+ </ footer >
You can’t perform that action at this time.
0 commit comments