Skip to content

symbolic links to git repositories are not resolved #59

@ZoomRmc

Description

@ZoomRmc

err := filepath.WalkDir(d.c.Repo.ScanPath, func(path string, de fs.DirEntry, err error) error {

legit uses basic filepath.WalkDir to scan for git directories which does not follow symlinks by design.

This could be changed to at least check symlinks for being git repos and add them without recursing into them.

Something like:

		if de.Type()&fs.ModeSymlink != 0 {
			resolvedPath, err := os.Readlink(path)
			if err != nil {
				log.Printf("failed to read symlink %s: %v", path, err)
				return nil 
			}
			if !filepath.IsAbs(resolvedPath) {
				resolvedPath = filepath.Join(filepath.Dir(path), resolvedPath)
			}
			checkPath = resolvedPath
		}

Then check checkPath with git.PlainOpen, if it is, resolve the canonical path to not add duplicates, and add to repos.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions