Switch to tagged update checks

This commit is contained in:
Paul Pfeister 2024-06-30 21:01:42 -04:00
parent 99586a56cf
commit 33db232493
No known key found for this signature in database
GPG key ID: 70D33A96CBD7A994
3 changed files with 8 additions and 12 deletions

View file

@ -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"

View file

@ -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"
)
latestReleaseJsonRaw = requests.get(forgeApiLatestReleaseUrl).text
latestReleaseJsonData = json_loads(latestReleaseJsonRaw)
latestRemoteTag = latestReleaseJsonData["tag_name"]
remote_version = str(re.findall('__version__ *= *"(.*)"', r.text)[0])
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:

View file

@ -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)