Skip to content

Commit 179509b

Browse files
laumannarthurzam
authored andcommitted
pkgdev mask: Accept -b/--bug for referencing bugs
When masking a package - and especially last-riting - the author should provide bug references. When --bug is given, the comment template is expanded to include the bug refs. Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz>
1 parent b8f38ac commit 179509b

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/pkgdev/scripts/pkgdev_mask.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from snakeoil.bash import iter_read_bash
1818
from snakeoil.cli import arghparse
1919
from snakeoil.osutils import pjoin
20+
from snakeoil.strings import pluralism
2021

2122
from .. import git
2223
from .argparsers import cwd_repo_argparser, git_repo_argparser
@@ -43,6 +44,13 @@
4344
package removal but accepts an optional argument for the number of
4445
days.
4546
""")
47+
mask_opts.add_argument(
48+
'-b', '--bug', dest='bugs', action='append', type=arghparse.positive_int,
49+
help='reference bug in the mask comment',
50+
docs="""
51+
Add a reference to a bug in the mask comment. May be specified multiple
52+
times to reference multiple bugs.
53+
""")
4654

4755

4856
@mask.bind_final_check
@@ -166,9 +174,14 @@ def __str__(self):
166174
return ''.join(self.header) + '\n\n'.join(map(str, self.masks))
167175

168176

169-
def get_comment():
177+
def get_comment(bugs):
170178
"""Spawn editor to get mask comment."""
171179
tmp = tempfile.NamedTemporaryFile(mode='w')
180+
if bugs:
181+
# Bug(s) #A, #B, #C
182+
bug_list = ", ".join(f'#{b}' for b in bugs)
183+
s = pluralism(bugs)
184+
tmp.write(f'\nBug{s} {bug_list}')
172185
tmp.write(textwrap.dedent("""
173186
174187
# Please enter the mask message. Lines starting with '#' will be ignored.
@@ -226,7 +239,7 @@ def _mask(options, out, err):
226239
'author': author,
227240
'email': email,
228241
'date': today.strftime('%Y-%m-%d'),
229-
'comment': get_comment(),
242+
'comment': get_comment(options.bugs),
230243
'atoms': options.atoms,
231244
}
232245

0 commit comments

Comments
 (0)