Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Added FollowLink() method to TreeEntry #114

Merged
merged 3 commits into from
Apr 19, 2018
Merged

Conversation

tf198
Copy link

@tf198 tf198 commented Apr 18, 2018

Solution for #63.

As symlinks are all mode 120000 we have to traverse the tree which is more expensive than a straight check so I've implemented it as a FollowLink() method and the caller can determine the type

if entry.IsLink() {
  target, err = entry.FollowLink()
  // err: on broken symlinks and targets outside repo
  if target.IsDir() {
    // isDirectorySymlink action
  } else {
    // isFileSymlink action (or a link, but would need to detect loops in recursive calls)
  }
}

Have a patch ready for go-gitea/gitea#1416 if this is accepted...

For testing I had to add files directly to the tests/repo1_bare and include them in the commit. If there is a cleaner way to do this I'm happy to resubmit.

Tris Forster added 2 commits April 18, 2018 15:51
Signed-off-by: Tris Forster <tris.git@shoddynet.org>
Signed-off-by: Tris Forster <tris.git@shoddynet.org>
Copy link
Author

@tf198 tf198 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this warning but CI jumped the gun - trying to kick it again

@lunny
Copy link
Member

lunny commented Apr 18, 2018

LGTM

@lafriks lafriks merged commit 288aede into go-gitea:master Apr 19, 2018
@tf198 tf198 deleted the follow_links branch April 19, 2018 04:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants