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

Issue #15723: Skip git ignored files in update-manifest. #19550

Merged
merged 1 commit into from Mar 27, 2018

Conversation

@kregoslup
Copy link
Contributor

kregoslup commented Dec 12, 2017

This patch makes "./mach update-manifest" aware of .gitignore.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #15725 (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because I don't know how to test it, I have tried mocking opening file and checking whether it exists but it's difficult to handle both in py2.7 and py3 and I think it would say too much about PathFilter internals. I have also tried mocking PathFilter but then I would be duplicating logic in tests.

This change is Reviewable

@highfive
Copy link

highfive commented Dec 12, 2017

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @emilio (or someone else) soon.

@tigercosmos
Copy link
Collaborator

tigercosmos commented Dec 25, 2017

r? @emilio

@jdm
Copy link
Member

jdm commented Jan 3, 2018

r? @jgraham
This touches enough code that I'm unfamiliar with that it would be good to have your eyes on it.

@highfive highfive assigned jgraham and unassigned emilio Jan 3, 2018
@nox
Copy link
Member

nox commented Jan 8, 2018

That change will get upstreamed automatically, right?

@jdm
Copy link
Member

jdm commented Jan 8, 2018

Yes.

@jgraham
Copy link
Contributor

jgraham commented Jan 8, 2018

So I think this is the wrong fix. update() is called with a tree object from the confusingly named vcs.py and the Git tree class presumably considers .gitignore by default and the FileSystem tree class imports and uses the gitignore module. So, unless I'm missing something, if this patch changes the behaviour, it's either because the existing code is buggy and should be fixed, or because the caller from the servo mach command is passing in the wrong kind of object. In either case the fix should be closer to the source.

@kregoslup
Copy link
Contributor Author

kregoslup commented Jan 31, 2018

OK, I think I found the bug but I'm not sure, can I ask a few questions?
Issue happens only in tests/wpt/mozilla/, because there is no .gitignore file in there. When

def update(tests_root, manifest, working_copy=False):
logger.info("Updating manifest")
tree = None
if not working_copy:
tree = vcs.Git.for_path(tests_root, manifest.url_base)
if tree is None:
tree = vcs.FileSystem(tests_root, manifest.url_base)
return manifest.update(tree)
update function calls manifest update with a tree object, either git tree or filesystem tree, PathFilter finds no .gitignore in that directory and here
class PathFilter(object):
def __init__(self, root, extras=None):
if root:
ignore_path = os.path.join(root, ".gitignore")
else:
ignore_path = None
if not ignore_path and not extras:
self.trivial = True
return
self.trivial = False
self.rules_file = []
self.rules_dir = []
if extras is None:
extras = []
if ignore_path and os.path.exists(ignore_path):
self._read_ignore(ignore_path)
for item in extras:
self._read_line(item)
has no extras argument and does not read gitignore file because it does not exists and trivial attribute is set to False because ignore_path variable is not None. My question is, which of these solutions do you think would be the best? I'm not sure what's the expected behaviour in this situation.

  1. Add .gitignore to tests/wpt/mozilla/ ?
  2. Add looking for additional gitignore files in other directiories?
  3. Change PathFilter behaviour to inform or log or set that it hasn't found any gitignore file in tests root directory or set its trivial attribute to True?

I think I'll go with 1 and 3, please let me know what do you think about that.

@jdm
Copy link
Member

jdm commented Feb 2, 2018

Let's add a .gitignore to tests/wpt/mozilla.

@kregoslup kregoslup force-pushed the kregoslup:issue_15725 branch from 687e637 to 8e05c5a Feb 4, 2018
@kregoslup kregoslup force-pushed the kregoslup:issue_15725 branch from 8e05c5a to 961e4a1 Feb 5, 2018
@jdm
Copy link
Member

jdm commented Mar 25, 2018

@kregoslup This PR now contains a single commit that only adds a .gitignore file. Where did the rest of the work go?

@kregoslup
Copy link
Contributor Author

kregoslup commented Mar 27, 2018

@jdm I figured out that the bug was only missing gitignore, so I amended previous commit and added only .gitignore file to path where it was missing. Do you mean that I should add tests?

@jdm
Copy link
Member

jdm commented Mar 27, 2018

@bors-servo r+
Oh, huh. That works for me!

@bors-servo
Copy link
Contributor

bors-servo commented Mar 27, 2018

📌 Commit 961e4a1 has been approved by jdm

@highfive highfive assigned jdm and unassigned jgraham Mar 27, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Mar 27, 2018

Testing commit 961e4a1 with merge 84513d4...

bors-servo added a commit that referenced this pull request Mar 27, 2018
Issue #15723: Skip git ignored files in update-manifest.

<!-- Please describe your changes on the following line: -->
This patch makes "./mach update-manifest" aware of .gitignore.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #15725 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because I don't know how to test it, I have tried mocking opening file and checking whether it exists but it's difficult to handle both in py2.7 and py3 and I think it would say too much about `PathFilter` internals. I have also tried mocking `PathFilter` but then I would be duplicating logic in tests.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19550)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 27, 2018

💔 Test failed - linux-rel-css

@jdm
Copy link
Member

jdm commented Mar 27, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Mar 27, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Mar 27, 2018

@bors-servo bors-servo merged commit 961e4a1 into servo:master Mar 27, 2018
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

8 participants
You can’t perform that action at this time.