@@ -521,6 +521,99 @@ def test_view_url_subdir(
521521 assert view_url == expected_url
522522 bundle .initialize .assert_not_called ()
523523
524+ @pytest .mark .parametrize (
525+ "repo_url, extra_conn_kwargs, expected_url" ,
526+ [
527+ (
528+ "git@github.com:apache/airflow.git" ,
529+ None ,
530+ "https://github.com/apache/airflow/tree/{version}/subdir" ,
531+ ),
532+ (
533+ "git@github.com:apache/airflow" ,
534+ None ,
535+ "https://github.com/apache/airflow/tree/{version}/subdir" ,
536+ ),
537+ (
538+ "https://github.com/apache/airflow" ,
539+ None ,
540+ "https://github.com/apache/airflow/tree/{version}/subdir" ,
541+ ),
542+ (
543+ "https://github.com/apache/airflow.git" ,
544+ None ,
545+ "https://github.com/apache/airflow/tree/{version}/subdir" ,
546+ ),
547+ (
548+ "git@gitlab.com:apache/airflow.git" ,
549+ None ,
550+ "https://gitlab.com/apache/airflow/-/tree/{version}/subdir" ,
551+ ),
552+ (
553+ "git@bitbucket.org:apache/airflow.git" ,
554+ None ,
555+ "https://bitbucket.org/apache/airflow/src/{version}/subdir" ,
556+ ),
557+ (
558+ "git@myorg.github.com:apache/airflow.git" ,
559+ None ,
560+ "https://myorg.github.com/apache/airflow/tree/{version}/subdir" ,
561+ ),
562+ (
563+ "https://myorg.github.com/apache/airflow.git" ,
564+ None ,
565+ "https://myorg.github.com/apache/airflow/tree/{version}/subdir" ,
566+ ),
567+ (
568+ "https://github.com/apache/airflow" ,
569+ {"password" : "abc123" },
570+ "https://github.com/apache/airflow/tree/{version}/subdir" ,
571+ ),
572+ (
573+ "https://github.com/apache/airflow" ,
574+ {"login" : "abc123" },
575+ "https://github.com/apache/airflow/tree/{version}/subdir" ,
576+ ),
577+ (
578+ "https://github.com/apache/airflow" ,
579+ {"login" : "abc123" , "password" : "def456" },
580+ "https://github.com/apache/airflow/tree/{version}/subdir" ,
581+ ),
582+ (
583+ "https://github.com:443/apache/airflow" ,
584+ None ,
585+ "https://github.com:443/apache/airflow/tree/{version}/subdir" ,
586+ ),
587+ (
588+ "https://github.com:443/apache/airflow" ,
589+ {"password" : "abc123" },
590+ "https://github.com:443/apache/airflow/tree/{version}/subdir" ,
591+ ),
592+ ],
593+ )
594+ @mock .patch ("airflow.providers.git.bundles.git.Repo" )
595+ def test_view_url_template_subdir (
596+ self , mock_gitrepo , repo_url , extra_conn_kwargs , expected_url , create_connection_without_db
597+ ):
598+ create_connection_without_db (
599+ Connection (
600+ conn_id = "git_default" ,
601+ host = repo_url ,
602+ conn_type = "git" ,
603+ ** (extra_conn_kwargs or {}),
604+ )
605+ )
606+ bundle = GitDagBundle (
607+ name = "test" ,
608+ tracking_ref = "main" ,
609+ subdir = "subdir" ,
610+ git_conn_id = "git_default" ,
611+ )
612+ bundle .initialize = mock .MagicMock ()
613+ view_url_template = bundle .view_url_template ()
614+ assert view_url_template == expected_url
615+ bundle .initialize .assert_not_called ()
616+
524617 @mock .patch ("airflow.providers.git.bundles.git.Repo" )
525618 def test_view_url_returns_none_when_no_version_in_view_url (self , mock_gitrepo ):
526619 bundle = GitDagBundle (
0 commit comments