Skip to content

Commit 7ae59b8

Browse files
Skip version check if request fails
1 parent 51cd464 commit 7ae59b8

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

app/cli.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,23 @@ def cli(ctx, verbose) -> None:
2626
ctx.ensure_object(dict)
2727
ctx.obj["VERBOSE"] = verbose
2828
current_version = Version.parse_version_string(__version__)
29-
tags = requests.get("https://api.github.com/repos/git-mastery/app/tags").json()
30-
latest_version = Version.parse_version_string(tags[0]["name"])
31-
if current_version.is_behind(latest_version):
32-
warn(
33-
click.style(
34-
f"Your version of Git-Mastery app {current_version} is behind the latest version {latest_version}.",
35-
fg="bright_red",
29+
req = requests.get("https://api.github.com/repos/git-mastery/app/tags")
30+
if req.ok:
31+
# Only continue with checks if request succeeds
32+
# Request could fail due to Github API rate limits or other errors
33+
tags = req.json()
34+
latest_version = Version.parse_version_string(tags[0]["name"])
35+
if current_version.is_behind(latest_version):
36+
warn(
37+
click.style(
38+
f"Your version of Git-Mastery app {current_version} is behind the latest version {latest_version}.",
39+
fg="bright_red",
40+
)
41+
)
42+
warn("We strongly recommend upgrading your app.")
43+
warn(
44+
f"Follow the update guide here: {click.style('https://git-mastery.github.io/app/update', bold=True)}"
3645
)
37-
)
38-
warn("We strongly recommend upgrading your app.")
39-
warn(
40-
f"Follow the update guide here: {click.style('https://git-mastery.github.io/app/update', bold=True)}"
41-
)
4246

4347

4448
def start() -> None:

0 commit comments

Comments
 (0)