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

Fix gitignore to not ignore files that are required #7538

Merged
merged 4 commits into from
Sep 21, 2023
Merged

Conversation

konstin
Copy link
Member

@konstin konstin commented Sep 20, 2023

It is apparently possible to add files to the git index, even if they are part of the gitignore (see e.g. https://stackoverflow.com/questions/45400361/why-is-gitignore-not-ignoring-my-files, even though it's strange that the gitignore entries existed before the files were added, i wouldn't know how to get them added in that case). I ran

git rm -r --cached .

then change the gitignore not actually ignore those files with the exception of crates/ruff_cli/resources/test/fixtures/cache_mutable/source.py, which is actually a generated file.

@charliermarsh
Copy link
Member

I haven't looked into this deeply but I think we need most of these files?

@konstin
Copy link
Member Author

konstin commented Sep 20, 2023

yes i think i have to fix the gitignore (and then figure out testing, because the files locally still exist, so the tests still pass, they are just deleted from what git tracks)

@konstin konstin changed the title git rm -r --cached . && git add . Fix gitignore to not ignore files that are required Sep 21, 2023
.gitignore Outdated
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
Copy link
Member Author

@konstin konstin Sep 21, 2023

Choose a reason for hiding this comment

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

personally, i'd just remove everything from gitignore we don't explicitly need. in this case, lib would ignore part of the resolver test case (and nobody should be writing e.g. eggs anymore anyway)

Also good news, venvs created by python -m venv will gitignore themselves from python 3.13 on: python/cpython#108125. venvs created by virtualenv already gitignore themselves for a while already (pypa/virtualenv#1825)

Copy link
Member

Choose a reason for hiding this comment

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

I personally find this useful because it matches the exact GitHub-recommended .gitignore, so it's easy to maintain and update in the future if needed.

@konstin konstin marked this pull request as ready for review September 21, 2023 07:59
@@ -1,3 +0,0 @@
a = 1

__all__ = list(["a", "b"])
Copy link
Member

Choose a reason for hiding this comment

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

What's the deal with this file? Is it just not used at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

The test cases create this file

test_cache.write_source_file("source.py", source);

.gitignore Outdated
@@ -169,6 +149,7 @@ venv/
ENV/
env.bak/
venv.bak/
!crates/ruff_python_resolver/resources/test/airflow/venv
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this up to the project-specific ignores at the top?

Copy link
Member Author

Choose a reason for hiding this comment

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

unfortunately not, the reinclusion needs to happen after the exclusion

@konstin
Copy link
Member Author

konstin commented Sep 21, 2023

I've changed it to a minimal diff

@konstin konstin merged commit c3774e1 into main Sep 21, 2023
16 checks passed
@konstin konstin deleted the clear-git-cache branch September 21, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants