From: Jan Kiszka <
jan.k...@siemens.com>
We are not running git interactively, so prevent that is tries to ask
for credentials when there is not chance to provide them.
However, we should keep interactive mode enabled when entering the
shell. Therefore, model removal and re-introduction as two commands. The
removal is part of the default setup_commands because even the shell
plugin runs non-interactive commands first. Before entering the shell,
the plugin can then restore interactive mode.
Changes in v2:
- stay interactive when entering the shell
kas/libcmds.py | 25 +++++++++++++++++++++++++
kas/plugins/shell.py | 3 ++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/kas/libcmds.py b/kas/libcmds.py
index 1758b9b..378594b 100644
--- a/kas/libcmds.py
+++ b/kas/libcmds.py
@@ -77,6 +77,7 @@ class Macro:
self.setup_commands += [(x, None) for x in [
SetupHome(),
+ MakeNonInteractive(),
InitSetupRepos(),
repo_loop,
FinishSetupRepos(),
@@ -372,6 +373,30 @@ class SetupHome(Command):
ctx.environ['HOME'] = self.tmpdirname
+class MakeNonInteractive(Command):
+ """
+ Make execution environment non-interactive
+ """
+
+ def __str__(self):
+ return 'make_non_interactive'
+
+ def execute(self, ctx):
+ ctx.environ['GIT_TERMINAL_PROMPT'] = 'false'
+
+
+class MakeInteractive(Command):
+ """
+ Make execution environment non-interactive
+ """
+
+ def __str__(self):
+ return 'make_non_interactive'
+
+ def execute(self, ctx):
+ ctx.environ['GIT_TERMINAL_PROMPT'] = 'true'
+
+
class SetupDir(Command):
"""
Creates the build directory.
diff --git a/kas/plugins/shell.py b/kas/plugins/shell.py
index 8fe1f36..1f9f29c 100644
--- a/kas/plugins/shell.py
+++ b/kas/plugins/shell.py
@@ -44,7 +44,7 @@ import os
import subprocess
from kas.context import create_global_context
from kas.config import Config
-from kas.libcmds import Macro, Command, SetupHome
+from kas.libcmds import Macro, Command, SetupHome, MakeInteractive
from kas.libkas import setup_parser_common_args, setup_parser_config_arg
from kas.libkas import setup_parser_keep_config_unchanged_arg
from kas.libkas import setup_parser_preserve_env_arg
@@ -90,6 +90,7 @@ class Shell:
run_handle_preserve_env_arg(ctx, os, args, SetupHome)
macro = Macro()
+ macro.add(MakeInteractive())
macro.add(ShellCommand(args.command))
macro.run(ctx, args.skip)
--
2.51.0