Repository: cekit/cekit
Pull request #871 (2023-09-07 12:54:49)

Modify git protocol


Patch:
diff --git a/cekit/builders/osbs.py b/cekit/builders/osbs.py
index 6426757..3ae29c8 100644
--- a/cekit/builders/osbs.py
+++ b/cekit/builders/osbs.py
@@ -295,7 +295,7 @@ class OSBSBuilder(Builder):
             # Parse the dist-git repository url
             url = urlparse(url)
             # Construct the url again, with a hash and removed username and password, if any
-            src = "https://{}/git{}#{}".format(url.hostname, url.path, commit)
+            src = "git+https://{}/git{}#{}".format(url.hostname, url.path, commit)
 
             target = self.generator.image.get("osbs", {}).get("koji_target")
 


Test patch:
diff --git a/tests/test_builder.py b/tests/test_builder.py
index c7dacdc..3ec675b 100644
--- a/tests/test_builder.py
+++ b/tests/test_builder.py
@@ -243,7 +243,7 @@ def test_osbs_builder_run_brew_stage(mocker):
                     "--python",
                     "buildContainer",
                     "--kwargs",
-                    "{'src': 'https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
+                    "{'src': 'git+https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
                 ],
                 stderr=-1,
                 stdout=-1,
@@ -302,7 +302,7 @@ def test_osbs_builder_run_brew(mocker):
                     "--python",
                     "buildContainer",
                     "--kwargs",
-                    "{'src': 'https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
+                    "{'src': 'git+https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
                 ],
                 stderr=-1,
                 stdout=-1,
@@ -361,7 +361,7 @@ def test_osbs_builder_run_koji(mocker):
                     "--python",
                     "buildContainer",
                     "--kwargs",
-                    "{'src': 'https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
+                    "{'src': 'git+https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
                 ],
                 stderr=-1,
                 stdout=-1,
@@ -433,7 +433,7 @@ def test_osbs_builder_run_brew_user(mocker):
             "--python",
             "buildContainer",
             "--kwargs",
-            "{'src': 'https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
+            "{'src': 'git+https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
         ],
         stderr=-1,
         stdout=-1,
@@ -474,7 +474,7 @@ def test_osbs_builder_run_brew_target_defined_in_descriptor(mocker):
             "--python",
             "buildContainer",
             "--kwargs",
-            "{'src': 'https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-target', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
+            "{'src': 'git+https://something.redhat.com/git/containers/openjdk#c5a0731b558c8a247dd7f85b5f54462cd5b68b23', 'target': 'some-target', 'opts': {'scratch': True, 'git_branch': 'some-branch', 'yum_repourls': []}}",
         ],
         stderr=-1,
         stdout=-1,
diff --git a/tests/test_integ_builder_osbs.py b/tests/test_integ_builder_osbs.py
index 87bb3cb..a770c3c 100644
--- a/tests/test_integ_builder_osbs.py
+++ b/tests/test_integ_builder_osbs.py
@@ -1142,7 +1142,7 @@ def test_osbs_builder_with_koji_target_based_on_branch(tmpdir, mocker, caplog):
     run_osbs(descriptor, str(tmpdir), mocker)
 
     assert (
-        "About to execute 'brew call --python buildContainer --kwargs {'src': 'https://somehost.com/git/containers/somerepo#3b9283cb26b35511517ff5c0c3e11f490cba8feb', 'target': 'branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'branch', 'yum_repourls': []}}'."
+        "About to execute 'brew call --python buildContainer --kwargs {'src': 'git+https://somehost.com/git/containers/somerepo#3b9283cb26b35511517ff5c0c3e11f490cba8feb', 'target': 'branch-containers-candidate', 'opts': {'scratch': True, 'git_branch': 'branch', 'yum_repourls': []}}'."
         in caplog.text
     )
 
@@ -1162,7 +1162,7 @@ def test_osbs_builder_with_koji_target_in_descriptor(tmpdir, mocker, caplog):
     run_osbs(descriptor, str(tmpdir), mocker)
 
     assert (
-        "About to execute 'brew call --python buildContainer --kwargs {'src': 'https://somehost.com/git/containers/somerepo#3b9283cb26b35511517ff5c0c3e11f490cba8feb', 'target': 'some-target', 'opts': {'scratch': True, 'git_branch': 'branch', 'yum_repourls': []}}'."
+        "About to execute 'brew call --python buildContainer --kwargs {'src': 'git+https://somehost.com/git/containers/somerepo#3b9283cb26b35511517ff5c0c3e11f490cba8feb', 'target': 'some-target', 'opts': {'scratch': True, 'git_branch': 'branch', 'yum_repourls': []}}'."
         in caplog.text
     )
 
@@ -2652,7 +2652,7 @@ def test_osbs_builder_kick_build_with_tag_1(tmpdir, mocker, caplog):
     )
     assert "Image was built successfully in OSBS!" in caplog.text
     assert (
-        "Tagging git repository (https://somehost.com/git/containers/somerepo#3b9283cb26b35511517ff5c0c3e11f490cba8feb) with FOOBAR-1 from build 123456"
+        "Tagging git repository (git+https://somehost.com/git/containers/somerepo#3b9283cb26b35511517ff5c0c3e11f490cba8feb) with FOOBAR-1 from build 123456"
         in caplog.text
     )
     assert (
@@ -2723,7 +2723,7 @@ def test_osbs_builder_kick_build_with_tag_2(tmpdir, mocker, caplog):
     )
     assert "Image was built successfully in OSBS!" in caplog.text
     assert (
-        "Tagging git repository (https://somehost.com/git/containers/somerepo#3b9283cb26b35511517ff5c0c3e11f490cba8feb) with test-image-1.0-1 from build 123456"
+        "Tagging git repository (git+https://somehost.com/git/containers/somerepo#3b9283cb26b35511517ff5c0c3e11f490cba8feb) with test-image-1.0-1 from build 123456"
         in caplog.text
     )
     assert (