repos: Keep repo name as read from config file

The Repo.factory method determines the name of each repo from either a
'name' property from the key used for this repo within the repos
dictionary. The Repo object should be initialised with this name instead
of dropping it and falling back to the basename of the path.

Signed-off-by: Paul Barker <pbarker@konsulko.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Paul Barker 2020-11-17 14:51:51 +01:00 committed by Jan Kiszka
parent d5eb961a44
commit d42df24afe

View File

@ -40,14 +40,14 @@ class Repo:
Represents a repository in the kas configuration. Represents a repository in the kas configuration.
""" """
def __init__(self, url, path, refspec, layers, patches, def __init__(self, name, url, path, refspec, layers, patches,
disable_operations): disable_operations):
self.name = name
self.url = url self.url = url
self.path = path self.path = path
self.refspec = refspec self.refspec = refspec
self._layers = layers self._layers = layers
self._patches = patches self._patches = patches
self.name = os.path.basename(self.path)
self.operations_disabled = disable_operations self.operations_disabled = disable_operations
def __getattr__(self, item): def __getattr__(self, item):
@ -132,10 +132,10 @@ class Repo:
path = os.path.join(get_context().kas_work_dir, path) path = os.path.join(get_context().kas_work_dir, path)
if typ == 'git': if typ == 'git':
return GitRepo(url, path, refspec, layers, patches, return GitRepo(name, url, path, refspec, layers, patches,
disable_operations) disable_operations)
if typ == 'hg': if typ == 'hg':
return MercurialRepo(url, path, refspec, layers, patches, return MercurialRepo(name, url, path, refspec, layers, patches,
disable_operations) disable_operations)
raise NotImplementedError('Repo type "%s" not supported.' % typ) raise NotImplementedError('Repo type "%s" not supported.' % typ)