From e1aca7cbddea61f0802810cd2a05fa121c3d15ef Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 12 Feb 2023 02:08:10 -0500 Subject: Deduplicate findReadmeFile() (#22177) This code was copy-pasted at some point. Revisit it to reunify it. ~~Doing that then encouraged simplifying the types of a couple of related functions.~~ ~~As a follow-up, move two helper functions, `isReadmeFile()` and `isReadmeFileExtension()`, intimately tied to `findReadmeFile()`, in as package-private.~~ Signed-off-by: Nick Guenther --- modules/git/tree_entry.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'modules') diff --git a/modules/git/tree_entry.go b/modules/git/tree_entry.go index 84b6ea4075..c4085c0278 100644 --- a/modules/git/tree_entry.go +++ b/modules/git/tree_entry.go @@ -101,6 +101,15 @@ func (te *TreeEntry) FollowLinks() (*TreeEntry, error) { return entry, nil } +// returns the subtree, or nil if this is not a tree +func (te *TreeEntry) Tree() *Tree { + t, err := te.ptree.repo.getTree(te.ID) + if err != nil { + return nil + } + return t +} + // GetSubJumpablePathName return the full path of subdirectory jumpable ( contains only one directory ) func (te *TreeEntry) GetSubJumpablePathName() string { if te.IsSubModule() || !te.IsDir() { -- cgit v1.2.3