[PATCH 1/2] lock: Stop deriving from Checkout plugin

2 views
Skip to first unread message

Jan Kiszka

unread,
Jun 4, 2026, 4:05:42 AMJun 4
to kas-devel, Felix Moessbauer
From: Jan Kiszka <jan.k...@siemens.com>

We will need to control the context prior to running the Macro, thus
will no longer be able to build on Checkout's run method. Therefore, the
value of deriving from this class becomes minimal, and it is cleaner to
just implement everything ourselves in the lock plugin.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
kas/plugins/lock.py | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/kas/plugins/lock.py b/kas/plugins/lock.py
index 20568d7..b6524ff 100644
--- a/kas/plugins/lock.py
+++ b/kas/plugins/lock.py
@@ -76,9 +76,11 @@
import logging
import os
from dataclasses import dataclass
-from kas.context import get_context
+from kas.context import create_global_context
+from kas.config import Config
from kas.includehandler import ConfigFile
-from kas.plugins.checkout import Checkout
+from kas.libcmds import Macro
+from kas.libkas import setup_parser_common_args, setup_parser_config_arg
from kas.plugins.dump import Dump, IoTarget, LOCKFILE_VERSION_MIN
from kas.plugins.diff import Diff
from kas.repos import Repo, RepoRefError
@@ -87,7 +89,7 @@ __license__ = 'MIT'
__copyright__ = 'Copyright (c) Siemens AG, 2024'


-class Lock(Checkout):
+class Lock:
"""
Implements a kas plugin to create and update kas project lockfiles.
"""
@@ -104,7 +106,8 @@ class Lock(Checkout):

@classmethod
def setup_parser(cls, parser):
- super().setup_parser(parser)
+ setup_parser_common_args(parser)
+ setup_parser_config_arg(parser)
Dump.setup_parser_format_args(parser)

def _print_log_diff(self, repo, old_commit):
@@ -192,8 +195,11 @@ class Lock(Checkout):
'write_bbconfig',
]

- super().run(args)
- ctx = get_context()
+ ctx = create_global_context(args)
+ ctx.config = Config(ctx, args.config)
+
+ macro = Macro()
+ macro.run(ctx, args.skip)
repos_cfg = ctx.config.repo_dict.items()
# when locking, only consider floating repos managed by kas
# Important: process repos in the order they are defined in the
--
2.47.3

Jan Kiszka

unread,
Jun 4, 2026, 4:06:10 AMJun 4
to kas-devel, Felix Moessbauer
From: Jan Kiszka <jan.k...@siemens.com>

This plugin is there to create or update pinnings, thus should not bark
at the user to call it when there is none yet or, even worse, while
updating existing ones.

Fixes: 397b10d5fab5 ("repos: Warn about repos with branches but without commit or lock file")
Reported-by: Felix Moessbauer <felix.mo...@siemens.com>
Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
kas/context.py | 1 +
kas/plugins/lock.py | 1 +
kas/repos.py | 3 ++-
3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/kas/context.py b/kas/context.py
index 5edb2d9..41bd761 100644
--- a/kas/context.py
+++ b/kas/context.py
@@ -100,6 +100,7 @@ class Context:
self.keyhandler = {}
self.config = None
self.args = args
+ self.unpinned_repo_warnings = True

def setup_initial_environ(self):
"""
diff --git a/kas/plugins/lock.py b/kas/plugins/lock.py
index b6524ff..2d947c8 100644
--- a/kas/plugins/lock.py
+++ b/kas/plugins/lock.py
@@ -197,6 +197,7 @@ class Lock:

ctx = create_global_context(args)
ctx.config = Config(ctx, args.config)
+ ctx.unpinned_repo_warnings = False

macro = Macro()
macro.run(ctx, args.skip)
diff --git a/kas/repos.py b/kas/repos.py
index 4d2a978..498ca19 100644
--- a/kas/repos.py
+++ b/kas/repos.py
@@ -297,7 +297,8 @@ class Repo:
'Unsupported mixture of legacy refspec and '
f'commit/tag/branch for repository "{name}"')
refspec = repo_overrides.get('commit', refspec)
- if not commit and name not in Repo.__no_commit_warned__:
+ if not commit and name not in Repo.__no_commit_warned__ \
+ and get_context().unpinned_repo_warnings:
if tag:
logging.warning('Using tag without commit for repository '
'"%s" is unsafe as tags are mutable.', name)
--
2.47.3

Reply all
Reply to author
Forward
0 new messages