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

Support other top-level gitignore locations #15935

Closed
rshin opened this issue Jun 24, 2022 · 4 comments · Fixed by #18649
Closed

Support other top-level gitignore locations #15935

rshin opened this issue Jun 24, 2022 · 4 comments · Fixed by #18649
Assignees
Labels
enhancement onboarding Issues that affect a new user's onboarding experience

Comments

@rshin
Copy link

rshin commented Jun 24, 2022

Is your feature request related to a problem? Please describe.
Pants uses patterns in the .gitignore to find additional files to ignore: https://www.pantsbuild.org/docs/reference-global#section-pants-ignore-use-gitignore

However, Git itself also looks at $GIT_DIR/info/exclude (usually .git/info/exclude) and $XDG_CONFIG_DIR/git/ignore (usually ~/.config/git/ignore, unless core.excludeFiles in ~/.gitconfig is set differently) to get additional ignore patterns: https://git-scm.com/docs/gitignore.

Describe the solution you'd like
It would be good if Pants supported these locations too.

This request is similar to #5682 but potentially simpler, as the interpretation of the patterns in these other ignore files is the same (they are relative to the repository root rather than some other location) and there is a fixed number of them.

Describe alternatives you've considered
You can replicate the additional ignore patterns in .pants.rc

@Eric-Arellano Eric-Arellano added the onboarding Issues that affect a new user's onboarding experience label Jun 24, 2022
@Eric-Arellano
Copy link
Contributor

Great idea! I added this to the Onboarding project and label. Fixing this means it's more likely Pants will Just Work on a new repo, which is an important goal for Pantsbuild.

@Eric-Arellano
Copy link
Contributor

Would you have any interest in implementing this? We'd be happy to try to scope out how this would work. It would involve writing some Rust code.

@sureshjoshi
Copy link
Member

Semi-relevant Slack thread example today:
https://pantsbuild.slack.com/archives/C046T6T9U/p1663933840682049

Summary: Bastian changed his pants_ignore which caused the .git to be picked up (because the default pants_ignore was overwritten) and caused test restarts due to filesystem changes in the now-watched git folder. Solution was to use pants_ignore.add instead.

However, when using this set of ignores:

pants_ignore.add = [
  "/apps/",
  "/src/bin",
  "/src/docker",
  "/frontend/",
  "/python/",
  ".idea/",
  "*.md",
]

This was popping up in the log: [INFO] notify invalidation: cleared 0 and dirtied 0 nodes for: {"pants-TODOS.md~"}

Because the tilde temp file wasn't in the .gitignore or pants_ignore anywhere.

On my machine, all of these temp files are excluded directly from my ~/.gitignore_global (same for .DS_Store files). I never really clued into why I was getting restarts in some of my tests or packages, but typically when they're going on, I stop saving any files in my working dir. I now think they might be caused by temp files being picked up sometimes by accident.

@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Apr 1, 2023

You were right that this indeed was more tractable than #5682. Thanks again for the suggestion!

See #18649.

@Eric-Arellano Eric-Arellano self-assigned this Apr 1, 2023
Eric-Arellano added a commit that referenced this issue Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement onboarding Issues that affect a new user's onboarding experience
Projects
Status: Done
3 participants