From d94e3a3431dc39e255ecedafcfb755f9834298ba Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Tue, 4 Jul 2017 18:50:28 +0200 Subject: [PATCH] Improve exit code implementation Unnecessary dynamic GitReviewException.EXIT_CODE attribute lookup refactored into static to benefit static analyzers. Default process exit code changed from 127 (command not found error) to 1 (general error) Change-Id: I1fcb583a740bf32c4427a587e208d099712a7bc4 --- git_review/cmd.py | 4 ++-- releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml diff --git a/git_review/cmd.py b/git_review/cmd.py index 15b04700..aeeecca3 100644 --- a/git_review/cmd.py +++ b/git_review/cmd.py @@ -75,7 +75,7 @@ class colors(object): class GitReviewException(Exception): - EXIT_CODE = 127 + EXIT_CODE = 1 class CommandFailed(GitReviewException): @@ -1704,7 +1704,7 @@ def main(): _main() except GitReviewException as e: print(e) - sys.exit(getattr(e, 'EXIT_CODE', -1)) + sys.exit(e.EXIT_CODE) if __name__ == "__main__": diff --git a/releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml b/releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml new file mode 100644 index 00000000..73657d65 --- /dev/null +++ b/releasenotes/notes/fix-exit-code-5ab7f6314976319f.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fixes ``gitreview`` process exit code to align with general + UNIX process exit code conventions. Specifically, default exit + code changed to ``1`` which stands for "general error".