@@ -248,7 +248,8 @@ def open_local_config_file(self):
248248 def do_hot_patches (self ):
249249 # Before logging anything, check that we need to do something
250250 ini_lines = read_platformio_ini_file (self .logic_state )
251- bad_git_tag_re = re .compile (r'(github\.com.+)@' )
251+
252+ bad_git_tag_re = re .compile (r'(^[^;\n]+github\.com.+)@' )
252253 if any (bad_git_tag_re .search (ini_line ) for ini_line in ini_lines ):
253254 log .warning ('Hot patching git tag specifiers!!!' )
254255 def patch_line (in_str : str ) -> str :
@@ -262,8 +263,6 @@ def patch_line(in_str: str) -> str:
262263 patch_line (line )
263264 for line in ini_lines
264265 ]
265- with open (Path (self .logic_state .fw_dir , 'platformio.ini' ).resolve (), 'w' ) as fp :
266- fp .writelines (ini_lines )
267266
268267 if self .logic_state .env_is_avr_based ():
269268 # hard match the entire line
@@ -278,8 +277,29 @@ def patch_line(in_str: str) -> str:
278277 good_platform_line if line == bad_platform_line else line
279278 for line in ini_lines
280279 ]
281- with open (Path (self .logic_state .fw_dir , 'platformio.ini' ).resolve (), 'w' ) as fp :
282- fp .writelines (ini_lines )
280+
281+ bad_ssd_1306_revision_re = re .compile (r'(ClutchplateDude/esp8266-oled-ssd1306\s*#\s*4\.6\.0)' )
282+ if any (bad_ssd_1306_revision_re .search (ini_line ) for ini_line in ini_lines ):
283+ log .warning ('Hot patching oled-ssd1306 revision!!!' )
284+ def patch_line (in_str : str ) -> str :
285+ if bad_ssd_1306_revision_re .search (in_str ):
286+ out_str = bad_ssd_1306_revision_re .sub (r'ClutchplateDude/esp8266-oled-ssd1306#4f596c75' , in_str )
287+ log .warning (f'Replacing { in_str } with { out_str } ' )
288+ return out_str
289+ else :
290+ return in_str
291+ ini_lines = [
292+ patch_line (line )
293+ for line in ini_lines
294+ ]
295+
296+ # Just re-read the ini file to see if we changed anything
297+ if ini_lines != read_platformio_ini_file (self .logic_state ):
298+ log .debug ('Writing out patched ini file' )
299+ with open (Path (self .logic_state .fw_dir , 'platformio.ini' ).resolve (), 'w' ) as fp :
300+ fp .writelines (ini_lines )
301+ else :
302+ log .debug ('No patches applied' )
283303
284304 def build_fw (self ):
285305 self .main_app .wSpn_build .setState (BusyIndicatorState .BUSY )
0 commit comments