Skip to content

Commit

Permalink
add an option to choose what to replace non iso characters with
Browse files Browse the repository at this point in the history
Some upstream repos use annoying version format like: 10.2-63.
When running through the service, : and - are deleted which generates
unusable/misleading version strings (10.263).

This patches adds an option (iso-cleanup-string) which allows to choose which charater/string
to use to replace the non iso ones.
Default value is '' which keeps the legacy behaviour.

For example
10.2-63 with iso-cleanup-string='.' will generate 10.2.63

Signed-off-by: Nicolas Morey-Chaisemartin <[email protected]>
  • Loading branch information
nmorey committed Sep 25, 2017
1 parent 3eed1f2 commit e313aaf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions TarSCM/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion TarSCM/scm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 3 additions & 0 deletions tar_scm.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,7 @@ which get maintained in the SCM. Can be used multiple times.</description>
<parameter name="changesauthor">
<description>Specify author of the changes file entry to be written. Defaults to first email entry in ~/.oscrc, or "[email protected]" if there is no .oscrc found.</description>
</parameter>
<parameter name="iso-cleanup-string">
<description>Characters [-:] are replaced by this string. Defaults to ''.</description>
</parameter>
</service>
5 changes: 5 additions & 0 deletions tests/githgtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))

0 comments on commit e313aaf

Please sign in to comment.