diff --git a/TarSCM/cli.py b/TarSCM/cli.py index 2072d708..b9e7f601 100644 --- a/TarSCM/cli.py +++ b/TarSCM/cli.py @@ -107,6 +107,10 @@ def parse_args(self, options): parser.add_argument('--history-depth', help='Obsolete osc service parameter that does ' 'nothing') + parser.add_argument('--iso-cleanup-string', + default='', + help='Characters [-:] are replace by this string.' + ' Defaults to ""') # This option is only used in test cases, in real life you would call # obs_scm instead parser.add_argument('--use-obs-scm', default = False, diff --git a/TarSCM/scm/base.py b/TarSCM/scm/base.py index 3009f36c..2c43d14b 100644 --- a/TarSCM/scm/base.py +++ b/TarSCM/scm/base.py @@ -213,7 +213,7 @@ def version_iso_cleanup(self, version): version = re.sub(r'([0-9]{4})-([0-9]{2})-([0-9]{2}) +' r'([0-9]{2})([:]([0-9]{2})([:]([0-9]{2}))?)?' r'( +[-+][0-9]{3,4})', r'\1\2\3T\4\6\8', version) - version = re.sub(r'[-:]', '', version) + version = re.sub(r'[-:]', self.args.iso_cleanup_string, version) return version def prepare_working_copy(self): diff --git a/tar_scm.service.in b/tar_scm.service.in index 386ef8b2..aa7a5158 100644 --- a/tar_scm.service.in +++ b/tar_scm.service.in @@ -153,4 +153,7 @@ which get maintained in the SCM. Can be used multiple times. Specify author of the changes file entry to be written. Defaults to first email entry in ~/.oscrc, or "opensuse-packaging@opensuse.org" if there is no .oscrc found. + + Characters [-:] are replaced by this string. Defaults to ''. + diff --git a/tests/githgtests.py b/tests/githgtests.py index b667c5ff..29ab5dbf 100644 --- a/tests/githgtests.py +++ b/tests/githgtests.py @@ -56,3 +56,8 @@ def test_versionformat_revision(self): basename = self.basename(version=self.abbrev_sha1s(self.rev(2))) th = self.assertTarOnly(basename) self.assertTarMemberContains(th, basename + '/a', '2') + + def test_version_iso_cleanup(self): + self.tar_scm_std('--versionformat', '3.0-5:256', + '--iso-cleanup-string', '==') + self.assertTarOnly(self.basename(version="3.0==5==256"))