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
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
0824d02cd6
commit
cafe12ed3d
1 changed files with 17 additions and 1 deletions
18
gitdch
18
gitdch
|
@ -161,11 +161,25 @@ parser.add_argument(
|
||||||
default=None
|
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()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if not options.package_name:
|
if not options.package_name:
|
||||||
parser.error(
|
parser.error(
|
||||||
'You must provide package name using -n/--package-name paramter')
|
'You must provide package name using -n/--package-name parameter')
|
||||||
|
|
||||||
# Initialize log
|
# Initialize log
|
||||||
log = logging.getLogger()
|
log = logging.getLogger()
|
||||||
|
@ -211,6 +225,8 @@ tag_commits = dict(
|
||||||
def clean_deb_version(version_name):
|
def clean_deb_version(version_name):
|
||||||
""" Clean debian version name """
|
""" Clean debian version name """
|
||||||
version_name = re.sub('^[^0-9]*', '', 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:
|
if options.version_suffix:
|
||||||
version_name += options.version_suffix
|
version_name += options.version_suffix
|
||||||
return version_name
|
return version_name
|
||||||
|
|
Loading…
Reference in a new issue