Skip to content
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

feat: ignore gitignore & bazleignore files #56

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doctree/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ func GetIndex(ctx context.Context, dataDir, indexDataDir, projectName string, au
return nil, errors.New("potentially malicious index name (this is likely a bug)")
}

// ignore .gitignore or .bazelignore file
if strings.Contains(indexName, ".gitignore") || strings.Contains(indexName, ".bazelignore") {
return nil, errors.New("files to be ignored")
Copy link
Member

Choose a reason for hiding this comment

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

I think for this to be useful we would need to look at / parse the .gitignore and .bazelignore files, then ignore those files, no?

Also, I think strings.Contains would be wrong here - we should ignore these at the time we produce the index, not inside of GetIndex.

Probbaly it would need to live inside the IndexDir methods of indexers themselves

index, err := indexer.IndexDir(ctx, dir)

but I'm not 100% sure right now, may not have much time on my end to find the best place for this.

Copy link
Author

Choose a reason for hiding this comment

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

Ah Yeah! This makes sense @slimsag

I will take a look at this 👀

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @slimsag

}

indexes := apischema.ProjectIndexes{}
dir, err := ioutil.ReadDir(filepath.Join(indexDataDir, indexName))
if os.IsNotExist(err) {
Expand Down