Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid version checking when version info is absent #2714

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/ansiblelint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,14 @@ def guess_install_method() -> str:

def get_version_warning() -> str:
"""Display warning if current version is outdated."""
# 0.1dev1 is special fallback version
if __version__ == "0.1.dev1":
return ""

msg = ""
data = {}
current_version = Version(__version__)

if not os.path.exists(CACHE_DIR):
os.makedirs(CACHE_DIR)
cache_file = f"{CACHE_DIR}/latest.json"
Expand Down Expand Up @@ -260,7 +265,6 @@ 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.[/]"
Expand Down
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__",)