From 1523863fed69242ce9e9122617009ed765f6a621 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 7 Apr 2020 23:54:24 +0200 Subject: [PATCH] #46: Don't crash if Sentry is enabled and greed isn't being run in a git repository --- utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 36866f6..296cbeb 100644 --- a/utils.py +++ b/utils.py @@ -17,9 +17,13 @@ except ModuleNotFoundError: if config["Error Reporting"]["sentry_token"] != \ "https://00000000000000000000000000000000:00000000000000000000000000000000@sentry.io/0000000": import raven - + import raven.exceptions + try: + release = raven.fetch_git_sha(os.path.dirname(__file__)) + except raven.exceptions.InvalidGitRepository: + release = "Unknown" sentry_client = raven.Client(config["Error Reporting"]["sentry_token"], - release=raven.fetch_git_sha(os.path.dirname(__file__)), + release=release, environment="Dev" if __debug__ else "Prod") else: sentry_client = None