-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for new version on status command
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# SPDX-FileCopyrightText: 2024-present Bernhard Scheirle | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
import packaging.version | ||
import requests | ||
import rich.console | ||
|
||
from git_gerrit.__about__ import __version__ | ||
|
||
class Version: | ||
version = __version__ | ||
|
||
@staticmethod | ||
def get_latest_version() -> str: | ||
try: | ||
r = requests.get("https://pypi.org/pypi/git-gerrit-bridge/json") | ||
return r.json()["info"]["version"] | ||
except: | ||
return Version.version | ||
|
||
@staticmethod | ||
def print_version_check(): | ||
latest = packaging.version.parse(Version.get_latest_version()) | ||
current = packaging.version.parse(Version.version) | ||
if current < latest: | ||
console = rich.console.Console() | ||
console.print() | ||
console.print( | ||
(" [red]![/] New version of [turquoise2]git gerrit[/] available: " | ||
f"{latest} (Currently installed {current})")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters