Browse Source

Prevent Git terminal interaction through the entire app

Users can not be expected to have a terminal (visible). Any interaction
attempt would seemingly hang the app.

This changes turn any such event into a crash/error.

Providing GUI-based alternatives for interaction is still necessary, but
an orthogonal effort

Ping datalad/datalad-gooey#177
Closes datalad/datalad-gooey#176
Michael Hanke 1 year ago
parent
commit
c4ad405303
1 changed files with 11 additions and 1 deletions
  1. 11 1
      datalad_gooey/app.py

+ 11 - 1
datalad_gooey/app.py

@@ -1,8 +1,9 @@
 import logging
 import sys
 from types import MappingProxyType
-from pathlib import Path
+from os import environ
 from outdated import check_outdated
+from pathlib import Path
 from PySide6.QtWidgets import (
     QApplication,
     QMenu,
@@ -70,6 +71,12 @@ class GooeyApp(QObject):
         # we cannot handle ANSI coloring
         dlcfg.set('datalad.ui.color', 'off', scope='override', force=True)
 
+        # prevent any terminal-based interaction of Git
+        # do it here, not just for command execution to also catch any possible
+        # ad-hoc Git calls
+        self._gittermprompt = environ.get('GIT_TERMINAL_PROMPT')
+        environ['GIT_TERMINAL_PROMPT'] = '0'
+
         # setup themeing before the first dialog goes up
         self._setup_looknfeel()
 
@@ -174,6 +181,9 @@ class GooeyApp(QObject):
 
     def deinit(self):
         dlui.ui.set_backend(self._prev_ui_backend)
+        # restore any possible term prompt setup
+        if self._gittermprompt:
+            environ['GIT_TERMINAL_PROMPT'] = self._gittermprompt
 
     #@cached_property not available for PY3.7
     @property