From 9549b6809129532c6e5b072fc8bb3ff14d77ff23 Mon Sep 17 00:00:00 2001 From: jakub-nt <175944085+jakub-nt@users.noreply.github.com> Date: Mon, 3 Nov 2025 14:16:26 +0100 Subject: [PATCH] Fixed 'added by' information getting wrongly overwritten during update Signed-off-by: jakub-nt <175944085+jakub-nt@users.noreply.github.com> --- cfbs/cfbs_json.py | 8 +++++--- cfbs/commands.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cfbs/cfbs_json.py b/cfbs/cfbs_json.py index 9bff7c0f..dc554366 100644 --- a/cfbs/cfbs_json.py +++ b/cfbs/cfbs_json.py @@ -13,13 +13,14 @@ from collections import OrderedDict from copy import deepcopy import logging as log +from typing import Optional from cfbs.index import Index from cfbs.pretty import pretty, TOP_LEVEL_KEYS, MODULE_KEYS from cfbs.utils import CFBSValidationError, read_json, CFBSExitError -def _construct_provided_module(name, data, url, commit, added_by="cfbs add"): +def _construct_provided_module(name, data, url, commit, added_by): # At this point the @commit part should be removed from url so: # either url should not have an @, # or the @ should be for user@host.something @@ -47,7 +48,8 @@ def _construct_provided_module(name, data, url, commit, added_by="cfbs add"): "missing required key 'steps' in module definition: %s" % pretty(data) ) module["steps"] = data["steps"] - module["added_by"] = added_by + if added_by is not None: + module["added_by"] = added_by return module @@ -172,7 +174,7 @@ def __getitem__(self, key): def __contains__(self, key): return key in self._data - def get_provides(self, added_by="cfbs add"): + def get_provides(self, added_by: Optional[str]): modules = OrderedDict() assert self._data is not None if "provides" not in self._data: diff --git a/cfbs/commands.py b/cfbs/commands.py index 2bcd8bbb..69224a6a 100644 --- a/cfbs/commands.py +++ b/cfbs/commands.py @@ -631,7 +631,7 @@ def update_command(to_update): ) module_name = old_module["name"] - provides = remote_config.get_provides() + provides = remote_config.get_provides(old_module.get("added_by")) if not module_name or module_name not in provides: continue