Git reference handling improvements
cover Git reference handling improvements
Ensure that Git references are not duplicated in user mode and adjust the reference ordering to prioritize static references. This makes the first static ref the default selection when available.
---
Daniel Gomez (2):
generate_refs: fix gitref duplicated refs
generate_refs: prioritize static refs in gitref generation
scripts/generate_refs.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
---
base-commit: 498f1007e222158e4d1b6f454217da8edc354252
change-id: 20250515-gitref-fixes-8815b7c2efab
Best regards,
Signature · 1 line
Daniel Gomez <[email protected]>
PATCH 1/2 generate_refs: fix gitref duplicated refs
From: Daniel Gomez <[email protected]>
Static references in YAML where not in consideration when using gitref for the final ref generated file. Read them first and exclude any git reference found that is already in the static list.
--- scripts/generate_refs.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
scripts/generate_refs.py +6 -3
@@ -257,7 +257,7 @@ def remote(args) -> List: return [heads["stdout"], tags["stdout"]] -def gitref_getreflist(args, reflist): +def gitref_getreflist(args, reflist, extraconfs): refs = [] for refline in reflist.splitlines(): if "^{}" in refline:
@@ -265,6 +265,8 @@ def gitref_getreflist(args, reflist): if len(refs) >= args.refs: break ref_name = refline.split("/")[-1] + if any(config["ref"] == ref_name for config in extraconfs): + continue refs.append(ref_name) logging.debug("release: {}".format(ref_name)) return refs
@@ -296,14 +298,15 @@ def gitref(args) -> None: # Only generate git reference if we have connection. Otherwise the output # file would contain static reference only and they should be already # part of the kreleases generation. + extraconfs = _get_extraconfs(args) if _check_connection("git.kernel.org", 80): reflist = [] refstr = remote(args) for rl in refstr: - _refs = gitref_getreflist(args, rl) + _refs = gitref_getreflist(args, rl, extraconfs) for r in _refs: reflist.append(r) - ref_generator(args, reflist, _get_extraconfs(args)) + ref_generator(args, reflist, extraconfs) def kreleases(args) -> None:
Signature · 1 line
2.49.0
PATCH 2/2 generate_refs: prioritize static refs in gitref generation
In reply to Daniel GomezFrom: Daniel Gomez <[email protected]>
Change the order of reference generation in gitref to prioritize static references. This ensures that a static ref, appears first in the list and is selected by default.
--- scripts/generate_refs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/generate_refs.py +2 -1
@@ -202,7 +202,6 @@ def ref_generator(args, reflist, extraconfs) -> None: f.write('\tprompt "Tag or branch to use"\n\n') logging.debug("Generating...") - refs.update(_ref_generator_choices(args, reflist, len(refs))) if extraconfs: for config in extraconfs:
@@ -212,6 +211,8 @@ def ref_generator(args, reflist, extraconfs) -> None: ) ) + refs.update(_ref_generator_choices(args, reflist, len(refs))) + with open(args.output, "a") as f: f.write("endchoice\n\n") f.write("config {}_REF\n".format(args.prefix))
Signature · 1 line
2.49.0
Quoted 5 lines · Daniel Gomez
Ensure that Git references are not duplicated in user mode and adjust the reference ordering to prioritize static references. This makes the first static ref the default selection when available.
Signed-off-by Daniel Gomez <[email protected]>
Luis