@@ -578,6 +578,71 @@ def test_scanner_updates_existing_registry_platforms(scan_plugins_module, tmp_pa
578578 assert metadata ["entries" ]["Plugin" ]["source" ] == "detected"
579579
580580
581+ def test_scanner_never_updates_existing_registry_branch (scan_plugins_module , tmp_path , monkeypatch ):
582+ registry_file = tmp_path / "registry.json"
583+ update_times_file = tmp_path / "update_times.json"
584+ metadata_file = tmp_path / "platform_detection.json"
585+ registry_file .write_text (json .dumps ({
586+ "Idle" : ["Idle" , "Idle" , "Idle" , "master" ],
587+ "luxtronikex" : [
588+ "Rouzax" ,
589+ "luxtronik-domoticz-plugin-v2" ,
590+ "description" ,
591+ "dist" ,
592+ "" ,
593+ ["linux" , "windows" ],
594+ ],
595+ }))
596+ update_times_file .write_text (json .dumps ({
597+ "luxtronikex" : "2026-03-14T14:52:18Z" ,
598+ }))
599+
600+ repo_info = {
601+ "archived" : False ,
602+ "disabled" : False ,
603+ "size" : 100 ,
604+ "full_name" : "Rouzax/luxtronik-domoticz-plugin-v2" ,
605+ "owner" : {"login" : "Rouzax" },
606+ "name" : "luxtronik-domoticz-plugin-v2" ,
607+ "description" : "updated description" ,
608+ "default_branch" : "main" ,
609+ "pushed_at" : "2026-07-02T11:45:18Z" ,
610+ }
611+
612+ seen_branches = []
613+
614+ def detect_platforms (owner , repo , branch , repo_info = None ):
615+ seen_branches .append (branch )
616+ return platform_decision (["linux" , "windows" ], confidence = "high" )
617+
618+ patch_scanner_paths (scan_plugins_module , monkeypatch , registry_file , update_times_file , metadata_file )
619+ monkeypatch .setattr (scan_plugins_module , "get_repo_info" , lambda owner , repo : repo_info )
620+ monkeypatch .setattr (scan_plugins_module , "search_github" , lambda : [])
621+ monkeypatch .setattr (scan_plugins_module , "search_gitlab" , lambda : [])
622+ monkeypatch .setattr (scan_plugins_module , "search_codeberg" , lambda : [])
623+ monkeypatch .setattr (scan_plugins_module , "detect_platforms_for_repo" , detect_platforms )
624+ monkeypatch .setenv ("GITHUB_TOKEN" , "test-token" )
625+
626+ scan_plugins_module .main ()
627+
628+ registry = json .loads (registry_file .read_text ())
629+ metadata = json .loads (metadata_file .read_text ())
630+
631+ assert seen_branches == ["dist" ]
632+ assert registry ["luxtronikex" ] == [
633+ "Rouzax" ,
634+ "luxtronik-domoticz-plugin-v2" ,
635+ "updated description" ,
636+ "dist" ,
637+ "" ,
638+ ["linux" , "windows" ],
639+ ]
640+ assert metadata ["entries" ]["luxtronikex" ]["branch" ] == "dist"
641+ assert metadata ["entries" ]["luxtronikex" ]["identity" ] == (
642+ "github.com/rouzax/luxtronik-domoticz-plugin-v2@dist"
643+ )
644+
645+
581646def test_scanner_adds_platforms_for_new_plugins (scan_plugins_module , tmp_path , monkeypatch ):
582647 registry_file = tmp_path / "registry.json"
583648 update_times_file = tmp_path / "update_times.json"
0 commit comments