From 21a80bfd9453a17905f8fbfd6dc1441d6e2e835b Mon Sep 17 00:00:00 2001 From: Ruslan Shymkevych Date: Wed, 25 Oct 2023 11:19:45 +0300 Subject: [PATCH] fetchers: disable prompt usage by git This commit addresses issue with git interacting with the user through the console. For example, HTTPS access to the private repo. We use git inside the hidden console, so user sees only hanging fetch. So, we instruct the git to not interact with the user by the command `GIT_TERMINAL_PROMPT=0`. As result, git fails cloning and inform user that asking name/password is not possible. This should push the user to use script-friendly authorization, like ssh. Suggested-by: Artem Mygaiev Signed-off-by: Ruslan Shymkevych Reviewed-by: Volodymyr Babchuk --- moulin/fetchers/git.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/moulin/fetchers/git.py b/moulin/fetchers/git.py index ef69020..180440e 100644 --- a/moulin/fetchers/git.py +++ b/moulin/fetchers/git.py @@ -18,14 +18,21 @@ def get_fetcher(conf: YamlValue, build_dir: str, generator: ninja_syntax.Writer) def gen_build_rules(generator: ninja_syntax.Writer): """Generate build rules using Ninja generator""" - # If $git_url uses ssh protocol and is not in .ssh/known_hosts, - # the ssh client starts to iterate with a user. - # But this interaction is not visible and - # looks just like the ninja hung on some operation. - # So we have to use ssh in BatchMode to throw - # an error instead of asking invisible questions. + # We use git with the console which is hidden from the user. + # That's why we need to disable any interaction with the user. + # Here we address two cases: + # + # SSH access to unknown host results in SSH asking confirmation + # from the user, so we use `GIT_SSH_COMMAND='ssh -o BatchMode=yes'` + # to inform user to add host manually. + # + # HTTPS access to private repo results in git asking for + # username/password. So we use `GIT_TERMINAL_PROMPT=0` + # to abort fetching and inform user, that may be other way should + # be used, like ssh. generator.rule("git_clone", command="GIT_SSH_COMMAND='ssh -o BatchMode=yes' " + "GIT_TERMINAL_PROMPT=0 " "git clone -q $git_url $git_dir && touch $out", description="git clone") generator.newline()