commit
message
General clean up
author
Ben Vogt <[email protected]>
date
2023-04-04 21:53:07
stats
1 file(s) changed,
22 insertions(+),
18 deletions(-)
files
main.go
1diff --git a/main.go b/main.go
2index 61cad4a..63f0888 100644
3--- a/main.go
4+++ b/main.go
5@@ -24,15 +24,25 @@ var htmlTemplates embed.FS
6 var config Config
7
8 func main() {
9+ var r *git.Repository = &git.Repository{}
10+ Init()
11+ CloneAndInfo(r)
12+ RenderLogPage(r)
13+ RenderAllCommitPages(r)
14+ RenderAllFilesPage()
15+ RenderSingleFilePages()
16+}
17+
18+func Init() {
19 config = DefaultConfig()
20 flag.StringVar(&config.Repo, "repo", "", "Repo to use.")
21 flag.BoolVar(&config.DebugOn, "debug", true, "Run in debug mode.")
22 flag.StringVar(&config.OutputDir, "output", "", "Dir of output.")
23- flag.StringVar(&config.CloneDir, "clone", "", "Directory to clone into. Defaults to /tmp/${rand}")
24+ flag.StringVar(&config.CloneDir, "clone", "", "Dir to clone into. Default is /tmp/${rand}")
25 flag.StringVar(&config.RepoData.BaseURL, "base-url", "/", "Base URL for serving.")
26 flag.StringVar(&config.RepoData.GitURL, "git-url", "", "Show where repo is hosted.")
27- flag.StringVar(&config.RepoData.Name, "name", "untitled repo", "Name for display")
28- flag.StringVar(&config.RepoData.Description, "desc", "untitled repo", "Description for display")
29+ flag.StringVar(&config.RepoData.Name, "name", "untitled repo", "Name to show")
30+ flag.StringVar(&config.RepoData.Description, "desc", "<no description>", "Description to show.")
31 flag.Parse()
32
33 if config.Repo == "" {
34@@ -49,21 +59,16 @@ func main() {
35 debug("output = %v", config.OutputDir)
36 debug("clone = %v", config.CloneDir)
37 debug("base-url = %v", config.RepoData.BaseURL)
38- r := CloneAndInfo()
39- config.RepoData.ReadMePath = findFileInRoot(config.AllowedReadMeFiles)
40- config.RepoData.LicenseFilePath = findFileInRoot(config.AllowedLicenseFiles)
41- RenderLogPage(r)
42- RenderAllCommitPages(r)
43- RenderAllFilesPage()
44- RenderSingleFilePages()
45 }
46
47-func CloneAndInfo() *git.Repository {
48- r, err := git.PlainClone(config.CloneDir, false, &git.CloneOptions{
49+func CloneAndInfo(r *git.Repository) {
50+ repo, err := git.PlainClone(config.CloneDir, false, &git.CloneOptions{
51 URL: config.Repo,
52 })
53 checkErr(err)
54- return r
55+ config.RepoData.ReadMePath = findFileInRoot(config.AllowedReadMeFiles)
56+ config.RepoData.LicenseFilePath = findFileInRoot(config.AllowedLicenseFiles)
57+ *r = *repo
58 }
59
60 func checkErr(err error) {