bd4b4351db372f3ce1c7f5d44211c1910d66c753

Author
Ayman Bagabas <ayman.bagabas@gmail.com>
Committer
Ayman Bagabas <ayman.bagabas@gmail.com>
Date

Message

fix: ignore directories when getting LatestFile

Diff

 1diff --git a/internal/git/git.go b/internal/git/git.go
 2index 05e2ab70fdcebb694767944653f64642d0787c43..728304d457ff1da377736390f17842c2f10def48 100644
 3--- a/internal/git/git.go
 4+++ b/internal/git/git.go
 5@@ -222,7 +222,8 @@ func (rs *RepoSource) LoadRepos() error {
 6 	return nil
 7 }
 8 
 9-// LatestFile returns the contents of the latest file at the specified path in the repository.
10+// LatestFile returns the contents of the latest file at the specified path in
11+// the repository and its file path.
12 func (r *Repo) LatestFile(pattern string) (string, string, error) {
13 	g := glob.MustCompile(pattern)
14 	dir := filepath.Dir(pattern)
15@@ -236,6 +237,9 @@ func (r *Repo) LatestFile(pattern string) (string, string, error) {
16 	}
17 	for _, e := range ents {
18 		fp := filepath.Join(dir, e.Name())
19+		if e.IsTree() {
20+			continue
21+		}
22 		if g.Match(fp) {
23 			bts, err := e.Contents()
24 			if err != nil {