Skip to content

Add go-gitignore dependency and update ignore handling in dump command #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 25, 2025

Conversation

catatsuy
Copy link
Owner

This pull request includes several changes to the internal/cli/dump.go file to improve the handling of ignore patterns and simplify the codebase. The key changes include adding support for .gitignore files, improving error handling, and removing the shouldIgnore function in favor of using the go-gitignore package.

Improvements to handling ignore patterns:

  • internal/cli/dump.go: Added support for .gitignore files by using the go-gitignore package and improved error handling when reading ignore files. [1] [2] [3] [4] [5] [6]
  • go.mod: Added github.com/sabhiram/go-gitignore to the module dependencies.

Codebase simplification:

Copy link

Automatic Review

The code changes made in the diff show significant updates, however, there are areas that could pose issues. Here are some of the concerns identified:

The addition of the github.com/sabhiram/go-gitignore dependency is a good idea for simplifying ignore pattern handling, but it may lead to a problem with completeness if the previously existing ignore functionality is not fully tested in the new implementation. Given that the old shouldIgnore function has been removed, it's crucial to ensure that all relevant tests are updated or rewritten to cover the new logic.

  • Testing: You removed the TestShouldIgnore function without replacing it with new tests that cover the behavior of the new ignoring logic using gitignore.CompileIgnoreLines.
    Suggestion: Create a new set of tests that validate the ignore functionality using the new library. This ensures that the changes you've made still behave as expected and do not introduce regressions.

    Example test case structure:

    func TestIgnorePatterns(t *testing.T) {
        ignores := gitignore.CompileIgnoreLines(".git/", "*.log", "node_modules/")
        tests := []struct {
            path     string
            expected bool
        }{
            {"test.txt", false},
            {".git/info/exclude", true},
            {"src/app.js", false},
            {"src/log.txt", true},
        }
        
        for _, test := range tests {
            t.Run(test.path, func(t *testing.T) {
                result := ignores.MatchesPath(test.path)
                if result != test.expected {
                    t.Errorf("MatchesPath(%q) = %v; want %v", test.path, result, test.expected)
                }
            })
        }
    }

Overall, while the code appears to improve readability and encapsulates responsibilities better with the new library, it is crucial to provide comprehensive testing to validate that the new implementation meets all requirements previously handled by the old shouldIgnore function.

@catatsuy catatsuy merged commit 7489fa4 into main Jan 25, 2025
6 checks passed
@catatsuy catatsuy deleted the feature-update-ignore-logic branch January 25, 2025 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant