1
0
Fork 0
forked from forgejo/forgejo

Render READMEs in docs/ .gitea or .github from root (#10361)

* Render READMEs in docs/ .gitea or .github from root
This commit is contained in:
zeripath 2020-02-21 23:04:20 +00:00 committed by GitHub
parent 6b019724f3
commit c8d1c38129
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 214 additions and 12 deletions

View file

@ -167,6 +167,38 @@ func (te *TreeEntry) FollowLink() (*TreeEntry, error) {
return target, nil
}
// FollowLinks returns the entry ultimately pointed to by a symlink
func (te *TreeEntry) FollowLinks() (*TreeEntry, error) {
if !te.IsLink() {
return nil, ErrBadLink{te.Name(), "not a symlink"}
}
entry := te
for i := 0; i < 999; i++ {
if entry.IsLink() {
next, err := entry.FollowLink()
if err != nil {
return nil, err
}
if next.ID == entry.ID {
return nil, ErrBadLink{
entry.Name(),
"recursive link",
}
}
entry = next
} else {
break
}
}
if entry.IsLink() {
return nil, ErrBadLink{
te.Name(),
"too many levels of symbolic links",
}
}
return entry, nil
}
// GetSubJumpablePathName return the full path of subdirectory jumpable ( contains only one directory )
func (te *TreeEntry) GetSubJumpablePathName() string {
if te.IsSubModule() || !te.IsDir() {