Skip to content

Commit

Permalink
Allow repository name change via git scm basename paramter
Browse files Browse the repository at this point in the history
Example:
https://github.com/DMTF/Redfishtool.git
vs
network:utilities/redfishtool

In mainline project the first letter 'R' is
uppercase, but in OBS it's lowercase.

Adding basename= parameter in _service file with this patch like:
     <param name="revision">main</param>
     <param name="versionformat">@PARENT_TAG@.@[email protected]%h</param>
     <param name="changesgenerate">enable</param>
-    </service>
+    <param name="basename">redfishtool</param>
+  </service>
   <service name="set_version" mode="localonly"/>
   <service name="tar" mode="buildtime">
   </service>

results in:
redfishtool
redfishtool-1.1.7.1.gfaa99dc.obscpio
redfishtool-1.1.7.1.gfaa99dc.tar.xz
redfishtool.obsinfo

instead of (without basename param):
Redfishtool
Redfishtool-1.1.7.1.gfaa99dc.obscpio
Redfishtool-1.1.7.1.gfaa99dc.tar.xz
Redfishtool.obsinfo

With this patch it is possible to adopt or rename
any arbitrary git project name to its matching OBS project
name and process it via OBS services.
  • Loading branch information
watologo1 authored and Thomas Renninger committed Aug 2, 2023
1 parent e7c0883 commit df59517
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions TarSCM/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self):
self.user = None
self.keyring_passphrase = None
self.changesgenerate = False
self.basename = None

def parse_args(self, options):
parser = argparse.ArgumentParser(description='Git Tarballs')
Expand Down Expand Up @@ -194,6 +195,12 @@ def parse_args(self, options):
'(only used with \'--latest-signed-*\')')
parser.add_argument('--without-version', default = False,
help='Do not add version to output file.')
parser.add_argument('--basename', default = None,
help='Checkout/rename and further process '
'repository as <BASENAME> (requires git scm).'
'Make sure there are no leftovers '
'(workrepo, obsinfo or obscpio) files from'
'a previous run')

self.verify_args(parser.parse_args(options))

Expand Down
7 changes: 4 additions & 3 deletions TarSCM/scm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, args, task):
self.repocachedir = None
self.clone_dir = None
self.lock_file = None
self.basename = None
self.basename = args.basename
self.repodir = None
self.user = None
self.password = None
Expand Down Expand Up @@ -288,8 +288,9 @@ def _calc_dir_to_clone_to(self, prefix):
# special handling for cloning bare repositories (../repo/.git/)
url_path = url_path.rstrip('/')

self.basename = os.path.basename(os.path.normpath(url_path))
self.basename = prefix + self.basename
if not self.basename:
self.basename = os.path.basename(os.path.normpath(url_path))
self.basename = prefix + self.basename

osc_version = 0

Expand Down
3 changes: 2 additions & 1 deletion tests/fake_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ class FakeCli(dict): # pylint: disable=no-init,too-few-public-methods
subdir = ''
user = ''
keyring_passphrase = ''
maintainers_asc = None
maintainers_asc = None
basename = None
def __init__(self, match_tag=False):
super(FakeCli, self).__init__()
self.match_tag = match_tag
Expand Down

0 comments on commit df59517

Please sign in to comment.