diff --git a/sherlock/__init__.py b/sherlock/__init__.py index 6f968d60..81e04b6a 100644 --- a/sherlock/__init__.py +++ b/sherlock/__init__.py @@ -9,5 +9,4 @@ __shortname__ = "Sherlock" __longname__ = "Sherlock: Find Usernames Across Social Networks" __version__ = "0.15.0" -forgeReleaseUrlPrefix = "https://github.com/sherlock-project/sherlock/releases/tag/" forgeApiLatestReleaseUrl = "https://api.github.com/repos/sherlock-project/sherlock/releases/latest" diff --git a/sherlock/sherlock.py b/sherlock/sherlock.py index 5a6caaaa..23c9a4d0 100644 --- a/sherlock/sherlock.py +++ b/sherlock/sherlock.py @@ -14,6 +14,7 @@ import os import re import sys from argparse import ArgumentParser, RawDescriptionHelpFormatter +from json import loads as json_loads from time import monotonic import requests @@ -24,8 +25,7 @@ from sherlock.__init__ import ( __longname__, __shortname__, __version__, - forgeReleaseUrlPrefix, - #forgeApiLatestReleaseUrl, + forgeApiLatestReleaseUrl, ) from sherlock.result import QueryStatus @@ -668,16 +668,14 @@ def main(): # Check for newer version of Sherlock. If it exists, let the user know about it try: - r = requests.get( - "https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock/__init__.py" - ) - - remote_version = str(re.findall('__version__ *= *"(.*)"', r.text)[0]) + latestReleaseJsonRaw = requests.get(forgeApiLatestReleaseUrl).text + latestReleaseJsonData = json_loads(latestReleaseJsonRaw) + latestRemoteTag = latestReleaseJsonData["tag_name"] - if remote_version != __version__: + if latestRemoteTag[1:] != __version__: print( - f"Update available! {__version__} --> {remote_version}" - f"\n{forgeReleaseUrlPrefix}v{remote_version}" + f"Update available! {__version__} --> {latestRemoteTag[1:]}" + f"\n{latestReleaseJsonData['html_url']}" ) except Exception as error: diff --git a/tests/test_version.py b/tests/test_version.py index 68119c9e..31578463 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -11,7 +11,6 @@ def test_versioning() -> None: expected:list = [ # Normalization is REQUIRED for Windows ( / vs \ ) os.path.normpath("sherlock/__init__.py"), - os.path.normpath("sherlock/sherlock.py"), ] # Sorting is REQUIRED for Mac assert sorted(found) == sorted(expected)