Skip to content

Commit

Permalink
Merge pull request #282 from alessiosavi/patch-1
Browse files Browse the repository at this point in the history
[parser.py] Avoid to raise exception in case of corrupt git folder
  • Loading branch information
FlyingBird95 committed Dec 5, 2019
2 parents c0d3604 + 8dbc660 commit 41717fc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions flask_monitoringdashboard/core/config/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ def parse_version(parser, header, version):
# The file is specified by: 'ref: <location>'
git_file = (open(os.path.join(git, 'HEAD')).read().rsplit(': ', 1)[1]).rstrip()
# read the git-version
version = open(git + '/' + git_file).read()
# cut version to at most 6 chars
return version[:6]
version_file = os.path.join(git , git_file)
if os.path.exists(version):
version = open(version).read()
# cut version to at most 6 chars
return version[:6]
else:
# Return "dummy" version in case of no git version file found
return version
except IOError:
log("Error reading one of the files to retrieve the current git-version.")
raise
Expand Down

0 comments on commit 41717fc

Please sign in to comment.