Add --exclude-unknown-project arg and corresponding config
This commit is contained in:
parent
f2b8776e21
commit
3e47f77f47
11 changed files with 118 additions and 18 deletions
|
@ -136,6 +136,10 @@ def parse_arguments():
|
|||
parser.add_argument('--exclude', dest='exclude', action='append',
|
||||
help='Filename patterns to exclude from logging. ' +
|
||||
'POSIX regex syntax. Can be used more than once.')
|
||||
parser.add_argument('--exclude-unknown-project',
|
||||
dest='exclude_unknown_project', action='store_true',
|
||||
help='When set, any activity where the project ' +
|
||||
'cannot be detected will be ignored.')
|
||||
parser.add_argument('--include', dest='include', action='append',
|
||||
help='Filename patterns to log. When used in ' +
|
||||
'combination with --exclude, files matching ' +
|
||||
|
@ -144,7 +148,7 @@ def parse_arguments():
|
|||
parser.add_argument('--include-only-with-project-file',
|
||||
dest='include_only_with_project_file',
|
||||
action='store_true',
|
||||
help='Disables tracking folders unless they contain '+
|
||||
help='Disables tracking folders unless they contain ' +
|
||||
'a .wakatime-project file. Defaults to false.')
|
||||
parser.add_argument('--ignore', dest='ignore', action='append',
|
||||
help=argparse.SUPPRESS)
|
||||
|
@ -243,6 +247,8 @@ def parse_arguments():
|
|||
args.include.append(pattern)
|
||||
except TypeError: # pragma: nocover
|
||||
pass
|
||||
if not args.exclude_unknown_project and configs.has_option('settings', 'exclude_unknown_project'):
|
||||
args.exclude_unknown_project = configs.getboolean('settings', 'exclude_unknown_project')
|
||||
if not args.hide_filenames and args.hidefilenames:
|
||||
args.hide_filenames = args.hidefilenames
|
||||
if args.hide_filenames:
|
||||
|
|
|
@ -94,6 +94,10 @@ class Heartbeat(object):
|
|||
self.project = project
|
||||
self.branch = branch
|
||||
|
||||
if self._excluded_by_unknown_project():
|
||||
self.skip = u('Skipping because project unknown.')
|
||||
return
|
||||
|
||||
try:
|
||||
stats = get_file_stats(self.entity,
|
||||
entity_type=self.type,
|
||||
|
@ -210,6 +214,11 @@ class Heartbeat(object):
|
|||
def _excluded_by_pattern(self):
|
||||
return should_exclude(self.entity, self.args.include, self.args.exclude)
|
||||
|
||||
def _excluded_by_unknown_project(self):
|
||||
if self.project:
|
||||
return False
|
||||
return self.args.exclude_unknown_project
|
||||
|
||||
def _excluded_by_missing_project_file(self):
|
||||
if not self.args.include_only_with_project_file:
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue