git2gpt icon indicating copy to clipboard operation
git2gpt copied to clipboard

Fix issue #9: symbolic link error

Open chand1012 opened this issue 8 months ago • 5 comments

This pull request fixes #9.

The issue has been successfully resolved by adding code to skip symbolic links during repository processing. The key change was in the processRepository function in prompt/prompt.go, where a check was added to detect and skip symbolic links:

// Skip symbolic links to avoid issues with directory symlinks (like Laravel's storage link)
if info.Mode()&os.ModeSymlink != 0 {
    return nil
}

This change specifically addresses the reported issue where Laravel's symbolic link from /storage to public/storage was causing git2gpt to fail with the error "read Codes/public/storage: is a directory". By detecting and skipping symbolic links, the tool will no longer attempt to traverse these links, preventing the error.

The PR also includes a test case (TestSymlinkHandling in cmd/symlink_test.go) that verifies the fix works correctly by ensuring that:

  1. The tool can process repositories containing symlinks without errors
  2. The actual files in the storage directory are properly included
  3. The symbolic links themselves are skipped

The test setup includes a sample directory structure that mimics the Laravel project structure that was causing the issue, with test files to validate the behavior.

Automatic fix generated by OpenHands 🙌

chand1012 avatar Mar 21 '25 01:03 chand1012