[PATCH] libcmds: Disable terminal prompts in git

1 view
Skip to first unread message

Jan Kiszka

unread,
Jan 28, 2026, 5:20:26 AM (13 days ago) Jan 28
to kas-devel, Jörg Sommer
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.

Suggested-by: Jörg Sommer <joerg....@navimatix.de>
Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
kas/libcmds.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kas/libcmds.py b/kas/libcmds.py
index 1758b9b..c938b68 100644
--- a/kas/libcmds.py
+++ b/kas/libcmds.py
@@ -318,7 +318,7 @@ class SetupHome(Command):
config.add_value(section, 'insteadOf',
f'ssh://git@{ci_ssh_host}:{ci_ssh_port}/')

- def _setup_gitconfig(self):
+ def _setup_gitconfig(self, ctx):
gitconfig_host = self._path_from_env('GITCONFIG_FILE')
gitconfig_kas = self.tmpdirname + '/.gitconfig'

@@ -355,6 +355,8 @@ class SetupHome(Command):
self._setup_gitlab_ci_ssh_rewrite(config)
config.write()

+ ctx.environ['GIT_TERMINAL_PROMPT'] = 'false'
+
def execute(self, ctx):
managed_env = get_context().managed_env
if managed_env:
@@ -365,7 +367,7 @@ class SetupHome(Command):
self._setup_netrc()
self._setup_npmrc()
self._setup_registry_auth()
- self._setup_gitconfig()
+ self._setup_gitconfig(ctx)
self._setup_aws_creds()
os.umask(def_umask)

--
2.51.0

MOESSBAUER, Felix

unread,
Jan 28, 2026, 5:28:31 AM (13 days ago) Jan 28
to Kiszka, Jan, kas-...@googlegroups.com, joerg....@navimatix.de
On Wed, 2026-01-28 at 11:20 +0100, 'Jan Kiszka' via kas-devel wrote:
> 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.
>
> Suggested-by: Jörg Sommer <joerg....@navimatix.de>
> Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
> ---
> kas/libcmds.py | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/kas/libcmds.py b/kas/libcmds.py
> index 1758b9b..c938b68 100644
> --- a/kas/libcmds.py
> +++ b/kas/libcmds.py
> @@ -318,7 +318,7 @@ class SetupHome(Command):
> config.add_value(section, 'insteadOf',
> f'ssh://git@{ci_ssh_host}:{ci_ssh_port}/')
>
> - def _setup_gitconfig(self):
> + def _setup_gitconfig(self, ctx):
> gitconfig_host = self._path_from_env('GITCONFIG_FILE')
> gitconfig_kas = self.tmpdirname + '/.gitconfig'
>
> @@ -355,6 +355,8 @@ class SetupHome(Command):
> self._setup_gitlab_ci_ssh_rewrite(config)
> config.write()
>
> + ctx.environ['GIT_TERMINAL_PROMPT'] = 'false'

This unfortunately modifies the global context, which also results in
having this setting in interactive sessions:

kas shell <...>
env | grep GIT
GIT_PROXY_COMMAND=oe-git-proxy
GIT_TERMINAL_PROMPT=false

Felix

--
Siemens AG
Linux Expert Center
Friedrich-Ludwig-Bauer-Str. 3
85748 Garching, Germany

Jan Kiszka

unread,
Jan 28, 2026, 6:38:17 AM (13 days ago) Jan 28
to Moessbauer, Felix (FT RPD CED OES-DE), kas-...@googlegroups.com, joerg....@navimatix.de
Was too easy. We could either remove the variable via the shell plugin
again or wrap all our git calls to have it only injected to them.

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center

Jan Kiszka

unread,
Jan 28, 2026, 8:57:31 AM (13 days ago) Jan 28
to kas-devel, Jörg Sommer, Felix Moessbauer
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.

Suggested-by: Jörg Sommer <joerg....@navimatix.de>
Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---

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

Florian Bezdeka

unread,
Jan 28, 2026, 9:29:02 AM (13 days ago) Jan 28
to Jan Kiszka, kas-devel, Jörg Sommer, Felix Moessbauer
This, as well as the class documentation above is a copy/paste error,
no?
> --
> You received this message because you are subscribed to the Google Groups "kas-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to kas-devel+...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/kas-devel/d76d95f8-9923-4b76-8aad-37b2fe3debca%40siemens.com.

Jan Kiszka

unread,
Jan 28, 2026, 9:41:30 AM (13 days ago) Jan 28
to Florian Bezdeka, kas-devel, Jörg Sommer, Felix Moessbauer
Hmpf, I thought I had fixed this - I didn't.

Thanks,
Jan

Jan Kiszka

unread,
Jan 28, 2026, 9:45:24 AM (13 days ago) Jan 28
to kas-devel, Jörg Sommer, Felix Moessbauer, Florian Bezdeka
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.

Suggested-by: Jörg Sommer <joerg....@navimatix.de>
Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---

Changes in v3:
- fix copy&paste mistakes in MakeInteractive

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..6dbffd2 100644
+ Make execution environment interactive
+ """
+
+ def __str__(self):
+ return 'make_interactive'

Jörg Sommer

unread,
Jan 28, 2026, 10:21:06 AM (12 days ago) Jan 28
to Jan Kiszka, kas-devel, Felix Moessbauer, Florian Bezdeka
Jan Kiszka schrieb am Mi 28. Jan, 15:45 (+0100):
> From: Jan Kiszka <jan.k...@siemens.com>
>
> We are not running git interactively, so prevent that is tries to ask

Should this be »prevent that i*t*«?

> 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.


--
Navimatix GmbH T: 03641 - 327 99 0
Tatzendpromenade 2 F: 03641 - 526 306
07745 Jena www.navimatix.de

Geschäftsführer: Steffen Späthe, Jan Rommeley
Registergericht: Amtsgericht Jena, HRB 501480

Jan Kiszka

unread,
Jan 28, 2026, 11:07:54 AM (12 days ago) Jan 28
to Jörg Sommer, kas-devel, Felix Moessbauer, Florian Bezdeka
On 28.01.26 16:20, Jörg Sommer wrote:
> Jan Kiszka schrieb am Mi 28. Jan, 15:45 (+0100):
>> From: Jan Kiszka <jan.k...@siemens.com>
>>
>> We are not running git interactively, so prevent that is tries to ask
>
> Should this be »prevent that i*t*«?

Yes... Will fix locally and push along with the next update.

Thanks,
Jan

>
>> 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.
>
>


--
Reply all
Reply to author
Forward
0 new messages