@@ -462,3 +462,51 @@ def test_analyze_repos_local_but_additional_dependencies() -> None:
462462 assert to_fix == {
463463 pre_commit_repo : PreCommitRepo ("https://repo_url" , "1.2.3" , [PreCommitHook ("hook" , ["lib-name==2.0.0" ])])
464464 }
465+
466+
467+ MOCK_DEP_MAPPING = {"dep" : {"repo" : "https://some.place" , "rev" : "${dev}" }}
468+ MOCK_REPO_ALIASES = {"https://some.place" : ("https://some.old.place" ,)}
469+
470+
471+ @patch ("sync_pre_commit_lock.actions.sync_hooks.DEPENDENCY_MAPPING" , MOCK_DEP_MAPPING )
472+ @patch ("sync_pre_commit_lock.actions.sync_hooks.REPOSITORY_ALIASES" , MOCK_REPO_ALIASES )
473+ def test_analyze_repos_renamed () -> None :
474+ printer = MagicMock (spec = Printer )
475+ pre_commit_config_file_path = MagicMock (spec = Path )
476+ locked_packages : dict [str , GenericLockedPackage ] = {"ruff" : GenericLockedPackage ("dep" , "1.2.3" )}
477+ plugin_config = SyncPreCommitLockConfig ()
478+
479+ syncer = SyncPreCommitHooksVersion (
480+ printer = printer ,
481+ pre_commit_config_file_path = pre_commit_config_file_path ,
482+ locked_packages = locked_packages ,
483+ plugin_config = plugin_config ,
484+ )
485+ pre_commit_repo = PreCommitRepo ("https://some.old.place" , "1.2.3" )
486+ pre_commit_repos = {pre_commit_repo }
487+
488+ to_fix , _ = syncer .analyze_repos (pre_commit_repos )
489+
490+ assert to_fix == {pre_commit_repo : PreCommitRepo ("https://some.place" , "1.2.3" )}
491+
492+
493+ @patch ("sync_pre_commit_lock.actions.sync_hooks.DEPENDENCY_MAPPING" , MOCK_DEP_MAPPING )
494+ @patch ("sync_pre_commit_lock.actions.sync_hooks.REPOSITORY_ALIASES" , MOCK_REPO_ALIASES )
495+ def test_analyze_repos_already_last_url () -> None :
496+ printer = MagicMock (spec = Printer )
497+ pre_commit_config_file_path = MagicMock (spec = Path )
498+ locked_packages : dict [str , GenericLockedPackage ] = {"ruff" : GenericLockedPackage ("dep" , "1.2.3" )}
499+ plugin_config = SyncPreCommitLockConfig ()
500+
501+ syncer = SyncPreCommitHooksVersion (
502+ printer = printer ,
503+ pre_commit_config_file_path = pre_commit_config_file_path ,
504+ locked_packages = locked_packages ,
505+ plugin_config = plugin_config ,
506+ )
507+ pre_commit_repo = PreCommitRepo ("https://some.place" , "1.2.3" )
508+ pre_commit_repos = {pre_commit_repo }
509+
510+ to_fix , _ = syncer .analyze_repos (pre_commit_repos )
511+
512+ assert to_fix == {}
0 commit comments