Compare commits

..

No commits in common. "a7de71882f8b388ebee1721e2923e2024254f796" and "5f71f435f7f0892bc88194e2a199efee7a769c80" have entirely different histories.

View file

@ -27,12 +27,12 @@ type RepoDir struct {
// ToDo: replace has* with the filename, as it can be bare or .md // ToDo: replace has* with the filename, as it can be bare or .md
type RepoInfo struct { type RepoInfo struct {
Name string Name string
Description string Description string
Url string Url string
Readme string HasReadme bool
License string HasLicense bool
Contributing string HasContributing bool
} }
type CommitFile struct { type CommitFile struct {
@ -69,9 +69,6 @@ type CommitInfo struct {
var embedTmpl embed.FS var embedTmpl embed.FS
var timeShortFormatStr = "2006-01-02 15:04" var timeShortFormatStr = "2006-01-02 15:04"
var timeLongFormatStr = time.RFC1123 var timeLongFormatStr = time.RFC1123
var readmeNames = []string{"README", "README.md", "README.txt"}
var licenseNames = []string{"LICENSE", "LICENSE.txt"}
var contributingNames = []string{"CONTRIBUTING", "CONTRIBUTING.txt"}
var funcMap = template.FuncMap{ var funcMap = template.FuncMap{
"inc": func(i int) int { "inc": func(i int) int {
return i + 1 return i + 1
@ -81,16 +78,16 @@ var funcMap = template.FuncMap{
menu += " | <a href=\"" + relpath + "files.html\">Files</a>" menu += " | <a href=\"" + relpath + "files.html\">Files</a>"
menu += " | <a href=\"" + relpath + "refs.html\">Refs</a>" menu += " | <a href=\"" + relpath + "refs.html\">Refs</a>"
if repoInfo.Readme != "" { if repoInfo.HasReadme {
menu += " | <a href=\"" + relpath + "file/" + repoInfo.Readme + ".html\">README</a>" menu += "| <a href=\"" + relpath + "file/README.html\">README</a>"
} }
if repoInfo.License != "" { if repoInfo.HasLicense {
menu += " | <a href=\"" + relpath + "file/" + repoInfo.License + ".html\">LICENSE</a>" menu += "| <a href=\"" + relpath + "file/LICENSE.html\">LICENSE</a>"
} }
if repoInfo.Contributing != "" { if repoInfo.HasContributing {
menu += " | <a href=\"" + relpath + "file/" + repoInfo.Contributing + ".html\">CONTRIBUTING</a>" menu += "| <a href=\"" + relpath + "file/CONTRIBUTING.html\">CONTRIBUTING</a>"
} }
return template.HTML(menu) return template.HTML(menu)
@ -274,27 +271,7 @@ func generateRepo(path string, logLimit int) error {
return fmt.Errorf("cannot get commit for hash %s: %w", head.Hash(), err) return fmt.Errorf("cannot get commit for hash %s: %w", head.Hash(), err)
} }
// populate Readme, License and Contributing // ToDo: populate hasReadme, hasLicense and hasContributing
for _, name := range readmeNames {
if _, err := c.File(name); err == nil {
repoInfo.Readme = name
break
}
}
for _, name := range licenseNames {
if _, err := c.File(name); err == nil {
repoInfo.License = name
break
}
}
for _, name := range contributingNames {
if _, err := c.File(name); err == nil {
repoInfo.Contributing = name
break
}
}
tree, err := c.Tree() tree, err := c.Tree()
if err != nil { if err != nil {
@ -385,7 +362,7 @@ func generateRepo(path string, logLimit int) error {
slog.Debug("Processing commit", "hash", c.Hash) slog.Debug("Processing commit", "hash", c.Hash)
if logLimit != 0 && i > logLimit { if i > logLimit {
remaining++ remaining++
slog.Debug("Limit reached while processing log", "iteration", i, "remaining", remaining) slog.Debug("Limit reached while processing log", "iteration", i, "remaining", remaining)
continue continue