From bd4b4351db372f3ce1c7f5d44211c1910d66c753 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 5 Apr 2022 19:14:43 -0400 Subject: [PATCH] fix: ignore directories when getting LatestFile --- internal/git/git.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/git/git.go b/internal/git/git.go index 05e2ab70fdcebb694767944653f64642d0787c43..728304d457ff1da377736390f17842c2f10def48 100644 --- a/internal/git/git.go +++ b/internal/git/git.go @@ -222,7 +222,8 @@ func (rs *RepoSource) LoadRepos() error { return nil } -// LatestFile returns the contents of the latest file at the specified path in the repository. +// LatestFile returns the contents of the latest file at the specified path in +// the repository and its file path. func (r *Repo) LatestFile(pattern string) (string, string, error) { g := glob.MustCompile(pattern) dir := filepath.Dir(pattern) @@ -236,6 +237,9 @@ func (r *Repo) LatestFile(pattern string) (string, string, error) { } for _, e := range ents { fp := filepath.Join(dir, e.Name()) + if e.IsTree() { + continue + } if g.Match(fp) { bts, err := e.Contents() if err != nil {