1package backend
2
3import (
4 "github.com/charmbracelet/soft-serve/git"
5 "github.com/charmbracelet/soft-serve/pkg/proto"
6)
7
8// LatestFile returns the contents of the latest file at the specified path in
9// the repository and its file path.
10func LatestFile(r proto.Repository, ref *git.Reference, pattern string) (string, string, error) {
11 repo, err := r.Open()
12 if err != nil {
13 return "", "", err //nolint:wrapcheck
14 }
15 return git.LatestFile(repo, ref, pattern) //nolint:wrapcheck
16}
17
18// Readme returns the repository's README.
19func Readme(r proto.Repository, ref *git.Reference) (readme string, path string, err error) {
20 pattern := "[rR][eE][aA][dD][mM][eE]*"
21 readme, path, err = LatestFile(r, ref, pattern)
22 return
23}