aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorNick2023-02-12 02:08:10 -0500
committerGitHub2023-02-12 15:08:10 +0800
commite1aca7cbddea61f0802810cd2a05fa121c3d15ef (patch)
treecd405aa2a759e5980e3ea9cfc584648d17a04c18 /modules
parentb0f18726a34edeb47b6442ce06ebee102b9c8a83 (diff)
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 <nick.guenther@polymtl.ca>
Diffstat (limited to 'modules')
-rw-r--r--modules/git/tree_entry.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/git/tree_entry.go b/modules/git/tree_entry.go
index 84b6ea407..c4085c027 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() {