Skip to content

Commit

Permalink
feat(backend): Support README files in the second-depth directories
Browse files Browse the repository at this point in the history
Many other Git platforms support them as well.
  • Loading branch information
5ouma committed Jan 15, 2025
1 parent 22d00e9 commit 17e8153
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/backend/utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package backend

import (
"fmt"

"github.com/charmbracelet/soft-serve/git"
"github.com/charmbracelet/soft-serve/pkg/proto"
)
Expand All @@ -18,6 +20,13 @@ func LatestFile(r proto.Repository, ref *git.Reference, pattern string) (string,
// Readme returns the repository's README.
func Readme(r proto.Repository, ref *git.Reference) (readme string, path string, err error) {
pattern := "[rR][eE][aA][dD][mM][eE]*"
readme, path, err = LatestFile(r, ref, pattern)
directories := []string{"", "docs", ".github", ".gitlab"}
for _, dir := range directories {
pattern := fmt.Sprintf("%s/%s", dir, pattern)
readme, path, err = LatestFile(r, ref, pattern)
if err == nil {
break
}
}
return
}

0 comments on commit 17e8153

Please sign in to comment.