jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/626415 )
Change subject: [bugfix] Fix path for stable release in version.getversion()
......................................................................
[bugfix] Fix path for stable release in version.getversion()
- stable release is a branch now and not a tag anymore. Fix this path
in getversion()
- Always try to get any online hash even the previous call fails
- show the branch (currently master/stable) instead of just "ok"
- Don't break if local hsh cannot be loaded
- This can be expanded for future tags like "4.4", "4.5",
"5.0"
Bug: T262558
Change-Id: Ic81923eb9bc1c8637051354d2fc7102eadcef24b
---
M pywikibot/version.py
1 file changed, 17 insertions(+), 9 deletions(-)
Approvals:
Matěj Suchánek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 5764bd4..a0d5eb0 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -55,23 +55,31 @@
return None
-def getversion(online=True):
+def getversion(online: bool = True) -> str:
"""Return a pywikibot version string.
- @param online: (optional) Include information obtained online
+ @param online: Include information obtained online
"""
+ branches = {
+ 'master': 'branches/master',
+ 'stable': 'branches/stable',
+ }
data = dict(getversiondict()) # copy dict to prevent changes in 'cache'
data['cmp_ver'] = 'n/a'
+ local_hsh = data.get('hsh', '')
+ hsh = {}
if online:
- with suppress(Exception):
- hsh3 = getversion_onlinerepo('tags/stable')
- hsh2 = getversion_onlinerepo()
- hsh1 = data['hsh']
- data['cmp_ver'] = 'UNKNOWN' if not hsh1 else (
- 'OUTDATED' if hsh1 not in (hsh2, hsh3) else 'ok')
+ if not local_hsh:
+ data['cmp_ver'] = 'UNKNOWN'
+ else:
+ for branch, path in branches.items():
+ with suppress(Exception):
+ hsh[getversion_onlinerepo(path)] = branch
+ if hsh:
+ data['cmp_ver'] = hsh.get(local_hsh, 'OUTDATED')
- data['hsh'] = data['hsh'][:7] # make short hash from full hash
+ data['hsh'] = local_hsh[:7] # make short hash from full hash
return '{tag} ({hsh}, {rev}, {date}, {cmp_ver})'.format_map(data)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/626415
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ic81923eb9bc1c8637051354d2fc7102eadcef24b
Gerrit-Change-Number: 626415
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged