repos: Warn if a repo uses legacy refspec

We are deprecating its usage but not yet removing it. Warn once per
parsed repo and kas run.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Jan Kiszka 2023-05-30 17:29:44 +02:00
parent bb48adad1f
commit c01a11833f

View File

@ -133,6 +133,8 @@ class Repo:
self.commit or self.branch or self.refspec, self.commit or self.branch or self.refspec,
self.path, self._layers) self.path, self._layers)
__legacy_refspec_warned__ = []
@staticmethod @staticmethod
def factory(name, repo_config, repo_defaults, repo_fallback_path, def factory(name, repo_config, repo_defaults, repo_fallback_path,
repo_overrides={}): repo_overrides={}):
@ -177,6 +179,11 @@ class Repo:
if refspec is None: if refspec is None:
commit = repo_overrides.get('refspec', commit) commit = repo_overrides.get('refspec', commit)
else: else:
if name not in Repo.__legacy_refspec_warned__:
logging.warning('Using deprecated refspec for repository '
'"%s". You should migrate to commit/branch.',
name)
Repo.__legacy_refspec_warned__.append(name)
if commit is not None or branch is not None: if commit is not None or branch is not None:
raise RepoRefError('Unsupported mixture of legacy refspec ' raise RepoRefError('Unsupported mixture of legacy refspec '
'and commit/branch for repository "{}"' 'and commit/branch for repository "{}"'