@@ -23,13 +23,27 @@ def __init__(
2323 self .config_path = config_path
2424 self .config_location = config_location
2525
26+ def _build_version_string (
27+ self , version : "Version" , second_version : "Version | None" = None
28+ ) -> "str" :
29+ """
30+ builds a version string, including second version if present
31+ """
32+ if second_version :
33+ return f"{ version } __{ second_version } "
34+ return str (version )
35+
2636 def _find_current_tag_prefix (self , content : "str" , plugin : "RHDHPlugin" ) -> "str" :
2737 """
2838 finds which tag prefix is currently being used for the plugin
2939 by searching the content for the plugin with any of the configured prefixes
3040 """
41+ version_string = self ._build_version_string (
42+ plugin .current_version , plugin .current_second_version
43+ )
44+
3145 for prefix in RHDHPluginUpdaterConfig .GH_PACKAGE_TAG_PREFIX :
32- test_tag = f"{ prefix } { plugin . current_version } "
46+ test_tag = f"{ prefix } { version_string } "
3347 pattern = re .compile (
3448 rf"package:\s+(?:oci://)?[^\s]*{ re .escape (plugin .plugin_name )} [^\s]*:{ re .escape (test_tag )} ![^\s]*" ,
3549 re .MULTILINE ,
@@ -44,20 +58,26 @@ def _update_plugin_version_in_content(
4458 content : "str" ,
4559 plugin : "RHDHPlugin" ,
4660 new_version : "Version" ,
61+ new_second_version : "Version | None" = None ,
4762 ) -> "str" :
4863 """
4964 update a single plugin version in the YAML content using string replacement.
5065 This preserves the original YAML formatting.
5166 """
67+ new_version_string = self ._build_version_string (new_version , new_second_version )
5268 logger .debug (
53- f"updating config for plugin { plugin .plugin_name } to version { new_version } "
69+ f"updating config for plugin { plugin .plugin_name } "
70+ f"to version { new_version_string } "
5471 )
5572
5673 # Find which tag prefix is currently used for this plugin
5774 current_prefix = self ._find_current_tag_prefix (content , plugin )
5875
59- old_tag = f"{ current_prefix } { plugin .current_version } "
60- new_tag = f"{ current_prefix } { new_version } "
76+ old_version_string = self ._build_version_string (
77+ plugin .current_version , plugin .current_second_version
78+ )
79+ old_tag = f"{ current_prefix } { old_version_string } "
80+ new_tag = f"{ current_prefix } { new_version_string } "
6181
6282 # pattern to find the specific plugin's package line with the old version
6383 pattern = re .compile (
@@ -71,12 +91,12 @@ def _update_plugin_version_in_content(
7191 if updated_content != content :
7292 logger .debug (
7393 f"updated config for { plugin .plugin_name } from "
74- f"{ plugin . current_version } to { new_version } "
94+ f"{ old_version_string } to { new_version_string } "
7595 )
7696 else :
7797 logger .warning (
7898 f"no match found for plugin { plugin .plugin_name } with version "
79- f"{ plugin . current_version } "
99+ f"{ old_version_string } "
80100 )
81101
82102 return updated_content
@@ -85,6 +105,7 @@ def update_rhdh_plugin(
85105 self ,
86106 rhdh_plugin : "RHDHPlugin" ,
87107 new_version : "Version" ,
108+ new_second_version : "Version | None" = None ,
88109 ) -> "str" :
89110 """
90111 updates a single plugin and return the updated YAML content.
@@ -93,7 +114,7 @@ def update_rhdh_plugin(
93114 content = f .read ()
94115
95116 updated_content = self ._update_plugin_version_in_content (
96- content , rhdh_plugin , new_version
117+ content , rhdh_plugin , new_version , new_second_version
97118 )
98119
99120 return updated_content
@@ -110,7 +131,10 @@ def bulk_update_rhdh_plugins(
110131
111132 for update in updates :
112133 content = self ._update_plugin_version_in_content (
113- content , update .rhdh_plugin , update .new_version
134+ content ,
135+ update .rhdh_plugin ,
136+ update .new_version ,
137+ update .new_second_version ,
114138 )
115139
116140 return content
0 commit comments