aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pkgdev/scripts/pkgdev_mask.py5
-rw-r--r--tests/scripts/test_pkgdev_mask.py23
2 files changed, 25 insertions, 3 deletions
diff --git a/src/pkgdev/scripts/pkgdev_mask.py b/src/pkgdev/scripts/pkgdev_mask.py
index 049c06c..1e47c15 100644
--- a/src/pkgdev/scripts/pkgdev_mask.py
+++ b/src/pkgdev/scripts/pkgdev_mask.py
@@ -160,7 +160,7 @@ class MaskFile:
comment = []
i = mask_lines[0] - 2
while i >= 0 and (line := lines[i].rstrip()):
- if not line.startswith('# '):
+ if not line.startswith('# ') and line != '#':
mask.error(f'invalid mask entry header, lineno {i + 1}: {line!r}')
comment.append(line[2:])
i -= 1
@@ -274,8 +274,7 @@ def _mask(options, out, err):
if options.rites:
removal_date = today + timedelta(days=options.rites)
- removal = removal_date.strftime('%Y-%m-%d')
- mask_args['comment'].append(f'Removal: {removal}')
+ mask_args['comment'].append(f'Removal: {removal_date:%Y-%m-%d}')
m = Mask(**mask_args)
mask_file.add(m)
diff --git a/tests/scripts/test_pkgdev_mask.py b/tests/scripts/test_pkgdev_mask.py
index 88898c0..aff8c89 100644
--- a/tests/scripts/test_pkgdev_mask.py
+++ b/tests/scripts/test_pkgdev_mask.py
@@ -194,6 +194,29 @@ class TestPkgdevMask:
self.script()
assert self.profile.masks == frozenset([atom_cls('cat/masked'), atom_cls('=cat/pkg-0')])
+ def test_invalid_header(self, capsys):
+ self.masks_path.write_text(textwrap.dedent("""\
+ # Random Dev <random.dev@email.com> (2022-09-09)
+ #
+ # Larry the Cow was here
+ #
+ # masked
+ cat/masked
+
+ # Larry the Cow <larry@gentoo.org> (2022-09-09)
+ #test
+ # Larry the Cow wasn't here
+ cat/masked2
+ """))
+
+ with os_environ(EDITOR="sed -i '1s/$/mask comment/'"), \
+ patch('sys.argv', self.args + ['=cat/pkg-0']), \
+ pytest.raises(SystemExit), \
+ chdir(pjoin(self.repo.path)):
+ self.script()
+ _, err = capsys.readouterr()
+ assert 'invalid mask entry header, lineno 9' in err
+
def test_invalid_author(self, capsys):
for line in (
'# Random Dev <random.dev@email.com>',