-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
dvc check-ignore
command
#4282
Merged
Merged
dvc check-ignore
command
#4282
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3a377ce
Update some tests first
karajan1001 32154f7
first edition
karajan1001 86a4ff7
solve failure in Windows
karajan1001 1f13e84
For Windows ci
karajan1001 c3e2fbd
Some help ducuments issue.
karajan1001 3eea263
Update dvc/ignore.py
karajan1001 76481bd
Merge remote-tracking branch 'origin/master' into fix_3736
karajan1001 27eec49
Refactor with OutOfWorkSpaceError
karajan1001 10d23e6
Solve a bug
karajan1001 0ac9c85
Update dvc/command/check_ignore.py
karajan1001 ab7237d
Update dvc/command/check_ignore.py
karajan1001 3cf35f0
Update dvc/command/check_ignore.py
efiop 4844735
Revert "Refactor with OutOfWorkSpaceError"
karajan1001 2749112
Merge remote-tracking branch 'origin/master' into fix_3736
karajan1001 4ee24f0
Two change request
karajan1001 54fbe31
Update dvc/main.py
karajan1001 930534b
`check_ignore` now only accept one path a time
karajan1001 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import argparse | ||
import logging | ||
|
||
from dvc.command import completion | ||
from dvc.command.base import CmdBase, append_doc_link | ||
from dvc.exceptions import DvcException | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class CmdCheckIgnore(CmdBase): | ||
def __init__(self, args): | ||
super().__init__(args) | ||
self.ignore_filter = self.repo.tree.dvcignore | ||
|
||
def _show_results(self, results): | ||
for result in results: | ||
if result.matches or self.args.non_matching: | ||
if self.args.details: | ||
logger.info( | ||
"{}\t{}".format(result.patterns[-1], result.file) | ||
) | ||
else: | ||
logger.info(result.file) | ||
|
||
def run(self): | ||
if self.args.non_matching and not self.args.details: | ||
raise DvcException("--non-matching is only valid with --details") | ||
|
||
if self.args.quiet and self.args.details: | ||
raise DvcException("cannot both --details and --quiet") | ||
|
||
results = self.ignore_filter.check_ignore(self.args.targets) | ||
self._show_results(results) | ||
if any(result.matches for result in results): | ||
return 0 | ||
return 1 | ||
|
||
|
||
def add_parser(subparsers, parent_parser): | ||
ADD_HELP = "Debug DVC ignore/exclude files" | ||
|
||
parser = subparsers.add_parser( | ||
"check-ignore", | ||
parents=[parent_parser], | ||
description=append_doc_link(ADD_HELP, "check-ignore"), | ||
help=ADD_HELP, | ||
formatter_class=argparse.RawDescriptionHelpFormatter, | ||
) | ||
parser.add_argument( | ||
"-d", | ||
"--details", | ||
action="store_true", | ||
default=False, | ||
help="Show the exclude pattern together with each target path.", | ||
) | ||
parser.add_argument( | ||
"-n", | ||
"--non-matching", | ||
action="store_true", | ||
default=False, | ||
help="Show the target paths which donβt match any pattern. " | ||
"Only usable when `--details` is also employed", | ||
) | ||
parser.add_argument( | ||
"targets", | ||
nargs="+", | ||
help="Input files/directories to check " "ignore patterns.", | ||
karajan1001 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
).complete = completion.FILE | ||
parser.set_defaults(func=CmdCheckIgnore) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like "Check whether files or directories are excluded due to
.dvcignore
." ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johntharian
No problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong handle π