Skip to content

Commit

Permalink
Avoid version checking when version info is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Nov 22, 2022
1 parent 465c058 commit 4341c2d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/ansiblelint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,15 @@ def get_version_warning() -> str:

html_url = data["html_url"]
new_version = Version(data["tag_name"][1:]) # removing v prefix from tag
# breakpoint()

if current_version > new_version:
msg = "[dim]You are using a pre-release version of ansible-lint.[/]"
elif current_version < new_version:
msg = f"""[warning]A new release of ansible-lint is available: [red]{current_version}[/] → [green][link={html_url}]{new_version}[/][/][/]"""
if current_version != "0.1.dev1":
if current_version > new_version:
msg = "[dim]You are using a pre-release version of ansible-lint.[/]"
elif current_version < new_version:
msg = f"""[warning]A new release of ansible-lint is available: [red]{current_version}[/] → [green][link={html_url}]{new_version}[/][/][/]"""

pip = guess_install_method()
if pip:
msg += f" Upgrade by running: [info]{pip}[/]"
pip = guess_install_method()
if pip:
msg += f" Upgrade by running: [info]{pip}[/]"

return msg
4 changes: 3 additions & 1 deletion src/ansiblelint/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

__version__ = pkg_resources.get_distribution("ansible-lint").version
except Exception: # pylint: disable=broad-except
__version__ = "unknown"
# this is the fallback SemVer version picked by setuptools_scm when tag
# information is not available.
__version__ = "0.1.dev1"

__all__ = ("__version__",)

0 comments on commit 4341c2d

Please sign in to comment.