sidetags: configurable naming template
Fixes: https://pagure.io/koji/issue/2893
This commit is contained in:
parent
cd1b928a5f
commit
ac4fb76b22
2 changed files with 10 additions and 1 deletions
|
|
@ -3,3 +3,7 @@
|
|||
remove_empty = off
|
||||
# potential suffixes for sidetag names
|
||||
# allowed_suffixes =
|
||||
# template for sidetag names. It must contain basetag and tag_id parts
|
||||
# if allowed_suffixes is not empty and suffix was requested, it will be added
|
||||
# as {name_template}-{suffix}. (percent-signs need to be escaped)
|
||||
# name_template = %%(basetag)s-sidetag-%%(tag_id)d
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ def createSideTag(basetag, debuginfo=False, suffix=None):
|
|||
# ugly, it will waste one number in tag_id_seq, but result will match with
|
||||
# id assigned by _create_tag
|
||||
tag_id = nextval("tag_id_seq") + 1
|
||||
sidetag_name = "%s-side-%s" % (basetag["name"], tag_id)
|
||||
sidetag_name = NAME_TEMPLATE % {'basetag': basetag["name"], 'tag_id': tag_id}
|
||||
if suffix:
|
||||
sidetag_name += '-%s' % suffix
|
||||
extra = {
|
||||
|
|
@ -314,9 +314,14 @@ def handle_sidetag_untag(cbtype, *args, **kws):
|
|||
# read config and register
|
||||
if not CONFIG:
|
||||
CONFIG = koji.read_config_files(CONFIG_FILE)
|
||||
print(open(CONFIG_FILE).read())
|
||||
if CONFIG.has_option("sidetag", "remove_empty") and CONFIG.getboolean(
|
||||
"sidetag", "remove_empty"
|
||||
):
|
||||
handle_sidetag_untag = callback("postUntag")(handle_sidetag_untag)
|
||||
if CONFIG.has_option("sidetag", "allowed_suffixes"):
|
||||
ALLOWED_SUFFIXES = CONFIG.get("sidetag", "allowed_suffixes").split(',')
|
||||
if CONFIG.has_option("sidetag", "name_template"):
|
||||
NAME_TEMPLATE = CONFIG.get("sidetag", "name_template")
|
||||
else:
|
||||
NAME_TEMPLATE = '%(basetag)s-side-%(tag_id)d'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue