[PATCH 1/3] diff: do not print filename if not provided

1 view
Skip to first unread message

Felix Moessbauer

unread,
Sep 2, 2025, 6:49:03 AM (6 days ago) Sep 2
to kas-...@googlegroups.com, jan.k...@siemens.com, Felix Moessbauer
In case only a commit diff is requested, we do not need to print the
filename, as the set of changes is anyways empty and the diff refers to
the whole repo.

Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
kas/plugins/diff.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kas/plugins/diff.py b/kas/plugins/diff.py
index c97adedf7..76e0fc3c2 100644
--- a/kas/plugins/diff.py
+++ b/kas/plugins/diff.py
@@ -165,9 +165,10 @@ class Diff:
{'color': COLORS_OLD, 'prefix': prefix_old},
'new_value':
{'color': COLORS_NEW, 'prefix': prefix_new}}
- print(f"kas diff {oldfile} {newfile}")
- print(prefix_old * 3, f" {oldfile}")
- print(prefix_new * 3, f" {newfile}")
+ if oldfile or newfile:
+ print(f"kas diff {oldfile} {newfile}")
+ print(prefix_old * 3, f" {oldfile}")
+ print(prefix_new * 3, f" {newfile}")
vc_dict = diff_output.get('values_changed', {})
vcs_dict = diff_output.get('vcs', {})
if vc_dict and not commit_only:
--
2.51.0

Felix Moessbauer

unread,
Sep 2, 2025, 6:49:03 AM (6 days ago) Sep 2
to kas-...@googlegroups.com, jan.k...@siemens.com, Felix Moessbauer
When updating the lockfile, we currently only print the old and the new
commit hashes. To make the output more meaningfull, we now also print
the commit log between both versions.

Signed-off-by: Felix Moessbauer <felix.mo...@siemens.com>
---
kas/plugins/lock.py | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/kas/plugins/lock.py b/kas/plugins/lock.py
index 05c5a8f1d..0676bd21b 100644
--- a/kas/plugins/lock.py
+++ b/kas/plugins/lock.py
@@ -80,6 +80,7 @@ from kas.context import get_context
from kas.includehandler import ConfigFile
from kas.plugins.checkout import Checkout
from kas.plugins.dump import Dump, IoTarget, LOCKFILE_VERSION_MIN
+from kas.plugins.diff import Diff
from kas.repos import Repo

__license__ = 'MIT'
@@ -106,6 +107,14 @@ class Lock(Checkout):
super().setup_parser(parser)
Dump.setup_parser_format_args(parser)

+ def _print_log_diff(self, repo, old_commit):
+ try:
+ diff = repo.diff(old_commit, None)
+ except NotImplementedError:
+ return
+ Diff.formatting_diff_output(
+ None, None, {'vcs': diff}, True, False, True, False)
+
def _update_lockfile(self, lockfile, repos_to_lock, update_only, args):
"""
Update all locks in the given lockfile.
@@ -138,6 +147,7 @@ class Lock(Checkout):
elif not lockfile.is_external:
logging.info('Updating lock of %s: %s -> %s',
r.name, v['commit'], r.revision)
+ self._print_log_diff(r, v['commit'])
v['commit'] = r.revision
changed = True
else:
--
2.51.0

Reply all
Reply to author
Forward
0 new messages