Skip to content

Commit 4e47412

Browse files
author
Robert Muchsel
authored
Catch git ValueError in update checker and continue (#238)
1 parent a851b64 commit 4e47412

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

izer/versioncheck.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###################################################################################################
2-
# Copyright (C) 2021 Maxim Integrated Products, Inc. All Rights Reserved.
2+
# Copyright (C) 2021-2022 Maxim Integrated Products, Inc. All Rights Reserved.
33
#
44
# Maxim Integrated Products, Inc. Default Copyright Notice:
55
# https://www.maximintegrated.com/en/aboutus/legal/copyrights.html
@@ -37,15 +37,19 @@ def check_repo(
3737
wprint('Cannot check for updates - no local repository.')
3838
return False
3939

40-
localrepo = git.Repo.init(folder)
41-
active_branch = localrepo.active_branch
42-
if verbose:
43-
print('Active branch:', active_branch, "(dirty)" if localrepo.is_dirty() else "")
40+
try:
41+
localrepo = git.Repo.init(folder)
42+
active_branch = localrepo.active_branch
43+
if verbose:
44+
print('Active branch:', active_branch, "(dirty)" if localrepo.is_dirty() else "")
4445

45-
localhead = localrepo.head.commit.hexsha
46-
localdate = datetime.datetime.utcfromtimestamp(localrepo.head.commit.committed_date)
47-
if verbose:
48-
print('LOCAL ', localhead, localdate)
46+
localhead = localrepo.head.commit.hexsha
47+
localdate = datetime.datetime.utcfromtimestamp(localrepo.head.commit.committed_date)
48+
if verbose:
49+
print('LOCAL ', localhead, localdate)
50+
except ValueError as exc:
51+
wprint('Cannot check for updates from GitHub -', str(exc))
52+
return False
4953

5054
retval = False
5155
g = github.Github()

0 commit comments

Comments
 (0)