Skip to content

Commit 0ed625d

Browse files
committed
Improved error logging, moved log into exception branch
1 parent c35f0a9 commit 0ed625d

2 files changed

Lines changed: 9 additions & 23 deletions

File tree

app/cli.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,17 @@ def cli(ctx: click.Context, verbose: bool) -> None:
5353
# GitHub redirects to the tag of the latest release; without the redirect
5454
# there is no version to compare against
5555
location = response.headers.get("Location")
56-
if location is not None:
56+
if location is None:
57+
warn(
58+
"Unable to verify the latest version release: no redirect to the latest "
59+
f"release tag (status {response.status_code})"
60+
)
61+
else:
5762
latest_version = Version.parse_version_string(location.rsplit("/", 1)[-1])
58-
except (requests.exceptions.RequestException, ValueError):
59-
latest_version = None
63+
except (requests.exceptions.RequestException, ValueError) as e:
64+
warn(f"Unable to verify the latest version release: {e}")
6065

61-
if latest_version is None:
62-
warn("Unable to verify the latest version release")
63-
elif current_version.is_behind(latest_version):
66+
if latest_version is not None and current_version.is_behind(latest_version):
6467
warn(
6568
click.style(
6669
f"Your version of Git-Mastery app {current_version} is behind the latest version {latest_version}.",

tests/e2e/test_version.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,3 @@ def test_version(runner: BinaryRunner) -> None:
77
res.assert_success()
88
res.assert_stdout_contains("Git-Mastery app is")
99
res.assert_stdout_matches(r"v\d+\.\d+\.\d+")
10-
11-
12-
def test_version_unreachable_release_check(runner: BinaryRunner) -> None:
13-
"""Commands still succeed when the latest release cannot be fetched."""
14-
# Route the release check through a closed port so it cannot connect.
15-
# NO_PROXY is cleared because an inherited value would bypass the proxy.
16-
res = runner.run(
17-
["version"],
18-
env={
19-
"HTTP_PROXY": "http://127.0.0.1:1",
20-
"HTTPS_PROXY": "http://127.0.0.1:1",
21-
"NO_PROXY": "",
22-
},
23-
)
24-
res.assert_success()
25-
res.assert_stdout_contains("Unable to verify the latest version release")
26-
res.assert_stdout_contains("Git-Mastery app is")

0 commit comments

Comments
 (0)