Skip to content

Commit dc9ad00

Browse files
committed
mask: better format for last rites with bugs
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 5ff74b7 commit dc9ad00

2 files changed

Lines changed: 11 additions & 12 deletions

File tree

src/pkgdev/scripts/pkgdev_mask.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,19 @@ def __str__(self):
189189
return ''.join(self.header) + '\n\n'.join(map(str, self.masks))
190190

191191

192-
def get_comment(bugs):
192+
def get_comment(bugs, rites: int):
193193
"""Spawn editor to get mask comment."""
194194
tmp = tempfile.NamedTemporaryFile(mode='w')
195+
summary = []
196+
if rites:
197+
summary.append(f'Removal: {datetime.now(timezone.utc) + timedelta(days=rites):%Y-%m-%d}.')
195198
if bugs:
196199
# Bug(s) #A, #B, #C
197200
bug_list = ", ".join(f'#{b}' for b in bugs)
198201
s = pluralism(bugs)
199-
tmp.write(f'\nBug{s} {bug_list}')
202+
summary.append(f'Bug{s} {bug_list}.')
203+
if summary := ' '.join(summary):
204+
tmp.write(f'\n{summary}')
200205
tmp.write(textwrap.dedent("""
201206
202207
# Please enter the mask message. Lines starting with '#' will be ignored.
@@ -268,14 +273,10 @@ def _mask(options, out, err):
268273
'author': author,
269274
'email': email,
270275
'date': today.strftime('%Y-%m-%d'),
271-
'comment': get_comment(options.bugs),
276+
'comment': get_comment(options.bugs, options.rites),
272277
'atoms': options.atoms,
273278
}
274279

275-
if options.rites:
276-
removal_date = today + timedelta(days=options.rites)
277-
mask_args['comment'].append(f'Removal: {removal_date:%Y-%m-%d}')
278-
279280
m = Mask(**mask_args)
280281
mask_file.add(m)
281282
mask_file.write()

tests/scripts/test_pkgdev_mask.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_last_rites(self):
259259
assert self.masks_path.read_text() == textwrap.dedent(f"""\
260260
# First Last <first.last@email.com> ({today})
261261
# mask comment
262-
# Removal: {removal}
262+
# Removal: {removal}.
263263
cat/pkg
264264
""")
265265
self.masks_path.write_text("") # Reset the contents of package.mask
@@ -290,13 +290,11 @@ def test_last_email_bad_mailer(self, capsys):
290290
assert err.strip() == "pkgdev mask: error: failed opening email composer"
291291

292292
def test_mask_bugs(self):
293-
removal_date = self.today + timedelta(days=30)
294293
today = self.today.strftime('%Y-%m-%d')
295-
removal = removal_date.strftime('%Y-%m-%d')
296294
for bflag in ('-b', '--bug'):
297295
for (bug_nums, expected) in [
298-
(['42'], 'Bug #42'),
299-
(['42', '43'], 'Bugs #42, #43'),
296+
(['42'], 'Bug #42.'),
297+
(['42', '43'], 'Bugs #42, #43.'),
300298
]:
301299
args = []
302300
for bug_num in bug_nums:

0 commit comments

Comments
 (0)