Shrividya commented on code in PR #64105:
URL: https://github.com/apache/airflow/pull/64105#discussion_r2976776489
##########
providers/git/src/airflow/providers/git/hooks/git.py:
##########
@@ -136,16 +136,24 @@ def _build_ssh_command(self, key_path: str | None = None)
-> str:
def _process_git_auth_url(self):
if not isinstance(self.repo_url, str):
return
- if self.auth_token and self.repo_url.startswith("https://"):
- self.repo_url = self.repo_url.replace("https://",
f"https://{self.user_name}:{self.auth_token}@")
- elif self.auth_token and self.repo_url.startswith("http://"):
- self.repo_url = self.repo_url.replace("http://",
f"http://{self.user_name}:{self.auth_token}@")
- elif self.repo_url.startswith("http://"):
- # if no auth token, use the repo url as is
- self.repo_url = self.repo_url
- elif not self.repo_url.startswith("git@") or not
self.repo_url.startswith("https://"):
+
+ if not self.repo_url.startswith("git@") or not
self.repo_url.startswith("https://"):
self.repo_url = os.path.expanduser(self.repo_url)
+ @contextlib.contextmanager
+ def _token_askpass_env(self):
+ if not self.auth_token:
+ yield
+ return
+
+ with tempfile.NamedTemporaryFile(mode="w", suffix=".sh", delete=True)
as askpass_script:
+ askpass_script.write(f"#!/bin/sh\necho '{self.auth_token}'\n")
Review Comment:
nit: might need escape sequences for the single quotes here as well.
--
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]