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

check root .gitignore in '_ignored' #3284

Merged
merged 6 commits into from
Feb 6, 2020
Merged

check root .gitignore in '_ignored' #3284

merged 6 commits into from
Feb 6, 2020

Conversation

ghost
Copy link

@ghost ghost commented Feb 6, 2020

  • ❗ Have you followed the guidelines in the Contributing to DVC list?

  • πŸ“– Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.

  • ❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addressed. Please review them carefully and fix those that actually improve code or fix bugs.

git: check if files are handled by root-dir .gitignore

When a file is already ignored through the root-dir .gitignore file, we don't want to add it to the "local" .gitignore file created by dvc

Fixes #1714

…t .gitignore. Added corresponding functional test
except GitCommandError:
# If none of the paths passed to `check_ignore` are ignored, GitPython annoyingly raises an Exception
pass

if os.path.exists(gitignore_path):
Copy link
Contributor

@efiop efiop Feb 6, 2020

Choose a reason for hiding this comment

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

Btw, we no longer need to manually read gitignore as if the entry is present there, check_ignore will tell us that. So we can safely remove the lines below.

Copy link
Author

Choose a reason for hiding this comment

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

ah interesting. Will change that

@efiop
Copy link
Contributor

efiop commented Feb 6, 2020

@Aljo-Rovco Thank for the PR! πŸ™ Looks great! Please see my comment above and also please install pre-commit hooks as described in https://dvc.org/doc/user-guide/contributing/core to check the formatting.

# by the .gitignore file in the root dir.

entry = (
entry[1:] if entry[0] == "/" else entry
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
entry[1:] if entry[0] == "/" else entry
entry = entry.lstrip("/")

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it won't be needed if we just pass path to _ignored() instead of putting the pieces back together.

Copy link
Author

Choose a reason for hiding this comment

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

hmm don't know what happened there haha

filter(lambda x: x.strip() == entry.strip(), ignore_list)
)
return False
def _ignored(self, entry, gitignore_path):
Copy link
Contributor

Choose a reason for hiding this comment

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

You can simply pass path to it now, since we no longer work with entries. πŸ™‚ Your PR is helping tidy this a lot πŸ™‚

@efiop
Copy link
Contributor

efiop commented Feb 6, 2020

@Aljo-Rovco Looks like formatting is still broken πŸ™ Please try running

$ pre-commit run --all-files

manually, it should fix it.

@efiop
Copy link
Contributor

efiop commented Feb 6, 2020

Thanks @Aljo-Rovco ! Looks great! There is one unrelated test failing due to some logging nuances, but I'll take it from here and will adjust it myself. Thank you so much!

@efiop efiop assigned efiop and ghost Feb 6, 2020
@efiop efiop merged commit e7b3297 into iterative:master Feb 6, 2020
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.

Add a way to suppress dvc changes to .gitignore
3 participants