From: Catalin Marinas Date: Tue, 13 Feb 2007 22:26:36 +0000 (+0000) Subject: Make StGIT aware of the STGIT_DEBUG_LEVEL environment variable X-Git-Tag: v0.12.1~16 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/stgit/commitdiff_plain/b2017c38acfed9c26ec5bbcb2b23784ca0a15cc8 Make StGIT aware of the STGIT_DEBUG_LEVEL environment variable For now, setting this environment variable will make StGIT dump the backtrace in case of a failure. Signed-off-by: Catalin Marinas --- diff --git a/stgit/main.py b/stgit/main.py index 49089e6..933f127 100644 --- a/stgit/main.py +++ b/stgit/main.py @@ -257,6 +257,14 @@ def main(): from stgit.commands.common import CmdException from stgit.gitmergeonefile import GitMergeException + try: + debug_level = int(os.environ['STGIT_DEBUG_LEVEL']) + except KeyError: + debug_level = 0 + except ValueError: + print >> sys.stderr, 'Invalid STGIT_DEBUG_LEVEL environment variable' + sys.exit(1) + try: config_setup() @@ -273,7 +281,10 @@ def main(): except (IOError, ParsingError, NoSectionError, CmdException, StackException, GitException, GitMergeException), err: print >> sys.stderr, '%s %s: %s' % (prog, cmd, err) - sys.exit(2) + if debug_level: + raise + else: + sys.exit(2) except KeyboardInterrupt: sys.exit(1) diff --git a/t/test-lib.sh b/t/test-lib.sh index 3274b84..0ac7e7c 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -63,6 +63,7 @@ do echo "$test_description" exit 0 ;; -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose) + export STGIT_DEBUG_LEVEL="-1" verbose=t; shift ;; *) break ;;