Skip to content

Commit 280c899

Browse files
committed
Fixes #1345
1 parent 1a39573 commit 280c899

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

cli/options.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ def parse_and_check(parser: ArgumentParser, logger_name: str = None, verify_toke
204204
__check_file_writeable(kwargs.get(REPORT_FILE, None))
205205
# Verify version randomly once every 10 runs
206206
if not kwargs[SKIP_VERSION_CHECK] and random.randrange(10) == 0:
207-
utilities.check_last_sonar_tools_version()
207+
if is_migration:
208+
utilities.check_last_version("https://pypi.org/simple/sonar-migration")
209+
else:
210+
utilities.check_last_version("https://pypi.org/simple/sonar-tools")
208211
kwargs.pop(SKIP_VERSION_CHECK, None)
209212
if utilities.is_sonarcloud_url(kwargs[URL]) and kwargs[ORG] is None:
210213
raise ArgumentsError(f"Organization (-{ORG_SHORT}) option is mandatory for SonarCloud")

sonar/utilities.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,20 @@
4545
DEFAULT = "__default__"
4646

4747

48-
def check_last_sonar_tools_version() -> None:
48+
def check_last_version(package_url: str) -> None:
4949
"""Checks last version of sonar-tools on pypi and displays a warning if the currently used version is older"""
5050
log.info("Checking latest sonar-version on pypi.org")
5151
try:
52-
r = requests.get(url="https://pypi.org/simple/sonar-tools", headers={"Accept": "application/vnd.pypi.simple.v1+json"}, timeout=10)
52+
r = requests.get(url=package_url, headers={"Accept": "application/vnd.pypi.simple.v1+json"}, timeout=10)
5353
r.raise_for_status()
5454
except (requests.RequestException, requests.exceptions.HTTPError, requests.exceptions.Timeout) as e:
5555
log.info("Can't access pypi.org, error %s", str(e))
5656
return
5757
txt_version = json.loads(r.text)["versions"][-1]
58-
log.info("Latest sonar-tools version is %s", txt_version)
58+
package_name = package_url.split("/")[-1]
59+
log.info("Latest %s version is %s", package_name, txt_version)
5960
if tuple(".".split(txt_version)) > tuple(".".split(version.PACKAGE_VERSION)):
60-
log.warning("A more recent version of sonar-tools (%s) is available, your are advised to upgrade", txt_version)
61+
log.warning("A more recent version of %s (%s) is available, your are advised to upgrade", package_name, txt_version)
6162

6263

6364
def token_type(token: str) -> str:

0 commit comments

Comments
 (0)