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(deps): pathspec update #25

Merged
merged 1 commit into from
Apr 11, 2024
Merged

fix(deps): pathspec update #25

merged 1 commit into from
Apr 11, 2024

Conversation

frichtarik
Copy link
Contributor

removing limit to pathspec<0.10.0 as the one failing integration test was IMHO incorrect

it expected to see visible files inside invisible folder, which is not a real situation
pathspec did fix the behavior, and so should we

  • github actions updates

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f7f6446) to head (611a150).

Additional details and impacted files
@@            Coverage Diff            @@
##            master       #25   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          196       196           
  Branches        34        34           
=========================================
  Hits           196       196           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@andhus andhus left a comment

Choose a reason for hiding this comment

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

Thanks @frichtarik 🙌

Yes, I agree! Limiting pathspec, as per your PR, was a good temporary solution to decouple other critical fixes from changing the behavior.

Regarding:

it expected to see visible files inside invisible folder, which is not a real situation

I think this could be something you might want to do (as in "be able to express") but the main point is what is expected for the specific match patterns provided.

In fact, there is no comprehensive definition for the patterns in the dirhash-standard (which is a critical weakness currently :/) but I think we should go by the claim in the README:

Glob/wildcard (".gitignore style") path matching for expressive filtering of files to include/exclude.

So we should follow how git/.gitignore works (which is exactly what pathspec fixed from >0.10 as I understand it). For future reference, a shell version of the updated test:

mkdir temp
cd temp
git init
mkdir d1 .d2
touch f1 .f2
touch d1/f1 d1/.f2
touch .d2/f1
echo ".*\n" > .gitignore
git add .
git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   d1/f1
	new file:   f1
rm .gitignore
git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   d1/f1
	new file:   f1

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	.d2/
	.f2
	d1/.f2

Please just see one comment re. the updated test case 🙏

@@ -284,9 +284,9 @@ def test_ignore_hidden_files(self):
# with ignore
filepaths = included_paths(
self.path_to('root'),
match=['*', '!.*']
match=['*', '!**/.*']
Copy link
Owner

@andhus andhus Apr 10, 2024

Choose a reason for hiding this comment

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

Could I please ask you to revert this and keep the original pattern here - this way it is clear that the expected behavior for the same scenario (same directory content and patterns) has changed as per this PR 👍

When we change both the patterns and the result one might think that the new outcome is attributed to the changed pattern, if you see my point?

So maybe rename this test case to just test_ignore_hidden (since it is not only ignoring .files) and duplicate it to a new test case named test_ignore_hidden_explicitly_recursive with your new pattern (I mean the plain .* also, in fact, matches recursively since d1/.f2 is ignored)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @andhus, i understand your concerns, thanks for the review.
In the end i've split the original test into 3, i'll add comments to the diff for simpler re-review

@andhus
Copy link
Owner

andhus commented Apr 10, 2024

And thanks for bumping the github action versions 👌

@@ -267,7 +267,7 @@ def test_cyclic_link(self):
with pytest.raises(SymlinkRecursionError):
filepaths = included_paths(self.path_to('root'))

def test_ignore_hidden_files(self):
def test_ignore_hidden(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. test (original) - i changed the name and the expected result for ignore codeblock, skipping '.d2/f1'

filepaths = included_paths(self.path_to('root'), match=['*', '!.*'])
assert filepaths == ['d1/f1', 'f1']

def test_ignore_hidden_files_only(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. test - after reading through suggested glob documentation, i was able to figure out combination of patterns that allow the original ignore result including visible file inside of hidden folder '.d2/f1'

assert filepaths == ['.d2/f1', 'd1/f1', 'f1']

def test_ignore_hidden_explicitly_recursive(self):
Copy link
Contributor Author

@frichtarik frichtarik Apr 11, 2024

Choose a reason for hiding this comment

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

  1. test - pattern '!**/.*' that leads to the same result as '!.*' (test 1) with the latest pathspec

@frichtarik frichtarik requested a review from andhus April 11, 2024 00:28
Copy link
Owner

@andhus andhus left a comment

Choose a reason for hiding this comment

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

Perfect, thanks!

@andhus andhus merged commit 7921fcd into andhus:master Apr 11, 2024
7 checks passed
@frichtarik frichtarik deleted the patch branch April 11, 2024 07:29
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.

2 participants