shunsuke-sugita commented on code in PR #64879:
URL: https://github.com/apache/airflow/pull/64879#discussion_r3069314479


##########
providers/git/src/airflow/providers/git/bundles/git.py:
##########
@@ -300,9 +300,13 @@ def _fetch_bare_repo(self):
         reraise=True,
     )
     def _fetch_submodules(self) -> None:
-        self._log.info("Initializing and updating submodules", 
repo_path=self.repo_path)
-        self.repo.git.submodule("sync", "--recursive")
-        self.repo.git.submodule("update", "--init", "--recursive", "--jobs", 
"1")
+        cm = nullcontext()
+        if self.hook and (cmd := self.hook.env.get("GIT_SSH_COMMAND")):
+            cm = self.repo.git.custom_environment(GIT_SSH_COMMAND=cmd)
+        with cm:
+            self._log.info("Initializing and updating submodules", 
repo_path=self.repo_path)
+            self.repo.git.submodule("sync", "--recursive")
+            self.repo.git.submodule("update", "--init", "--recursive", 
"--jobs", "1")

Review Comment:
   added tests in providers/git/tests/unit/git/bundles/test_git.py that assert 
custom_environment(GIT_SSH_COMMAND=...) when hook.env includes it, that 
submodule sync/update run inside that context (context manager 
__enter__/__exit__ and call order on repo.git), and that custom_environment is 
not used when GIT_SSH_COMMAND is missing.
   
   
[7e67b4c](https://github.com/apache/airflow/pull/64879/commits/7e67b4c5587e2df2b0cc4485b99ed78c47d9277a)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to