Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add an option to choose what to replace non iso characters with #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))