Add -C/--clean-tags-regex to allow tag names cleaning when computing package version
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Benjamin Renard 2022-12-12 14:33:31 +01:00
parent 0824d02cd6
commit cafe12ed3d

18
gitdch
View file

@ -161,11 +161,25 @@ parser.add_argument(
default=None
)
parser.add_argument(
'-C', '--clean-tags-regex',
action='append',
type=re.compile,
dest='clean_tags_regex',
help=(
'Clean tags regex: you could specify regex to clean tag names when '
'computing package versions. For instance, to drop a "-eeXXX" suffix '
'of tag names, specify -C "\\-ee[0-9]{3}$" (optional, multiple regex '
'allowed)'
),
default=[]
)
options = parser.parse_args()
if not options.package_name:
parser.error(
'You must provide package name using -n/--package-name paramter')
'You must provide package name using -n/--package-name parameter')
# Initialize log
log = logging.getLogger()
@ -211,6 +225,8 @@ tag_commits = dict(
def clean_deb_version(version_name):
""" Clean debian version name """
version_name = re.sub('^[^0-9]*', '', version_name)
for clean_regex in options.clean_tags_regex:
version_name = clean_regex.sub('', version_name)
if options.version_suffix:
version_name += options.version_suffix
return version_name