DrTrigon has uploaded a new change for review. https://gerrit.wikimedia.org/r/81197
Change subject: bug fix from core and sync (to core) for version handling ...................................................................... bug fix from core and sync (to core) for version handling * git version info extraction was buggy * minor changes introduced in core were ported Change-Id: I0a82d5c2139fdcbe27be64a39f0647e6be9be700 --- M pywikibot/version.py 1 file changed, 17 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/pywikibot/compat refs/changes/97/81197/1 diff --git a/pywikibot/version.py b/pywikibot/version.py index a9c6344..4cafdb0 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -41,6 +41,7 @@ data['hsh'] = data['hsh'][:7] # make short hash from full hash return '%(tag)s (r%(rev)s, %(hsh)s, %(date)s, %(cmp_ver)s)' % data + def getversiondict(): global cache if cache: @@ -90,7 +91,7 @@ name, tag, rev, date = cur.fetchone() con.close() tag = tag[:-len(name)] - date = time.gmtime(date/1000000) + date = time.gmtime(date / 1000000) else: for i in xrange(3): entries.readline() @@ -107,6 +108,7 @@ raise ParseError return (tag, rev, date) + def getversion_git(path=None): _program_dir = path or _get_program_dir() #(try to use .git directory for new entries format) @@ -116,23 +118,27 @@ tag = open(os.path.join(_program_dir, '.git/config'), 'r').read() s = tag.find('url = ', tag.find('[remote "origin"]')) e = tag.find('\n', s) - tag = tag[(s+6):e] + tag = tag[(s + 6):e] t = tag.strip().split('/') - tag = '[%s] %s' % (t[0][:-1], '/'.join(t[3:])[:-4]) + tag = '[%s] %s' % (t[0][:-1], '/'.join(t[3:])[:-4]) + path = os.path.abspath(os.curdir) + os.chdir(_program_dir) info = subprocess.Popen("git log --pretty=format:'%ad|%an|%h|%H|%d' --abbrev-commit --date=iso -1 | cat -", shell=True, stdout=subprocess.PIPE).stdout.read() info = info.split('|') date = info[0][:-6] date = time.strptime(date, '%Y-%m-%d %H:%M:%S') - rev = subprocess.Popen('git rev-list HEAD | wc -l', - shell=True, - stdout=subprocess.PIPE).stdout.read() - rev = int(rev.strip()) - hsh = info[3] # also stored in '.git/refs/heads/master' + rev = subprocess.Popen('git rev-list HEAD | wc -l', + shell=True, + stdout=subprocess.PIPE).stdout.read() + os.chdir(path) + rev = int(rev.strip()) + hsh = info[3] # also stored in '.git/refs/heads/master' if (not date or not tag or not rev) and not path: raise ParseError return (tag, rev, date, hsh) + def getversion_nightly(): data = open(os.path.join(wikipediatools.get_base_dir(), 'version')) @@ -142,6 +148,7 @@ if not date or not tag or not rev: raise ParseError return (tag, rev, date, '(unknown)') + def getversion_onlinerepo(repo=None): """ Retrieve revision number of framework online repository's svnroot """ @@ -156,7 +163,7 @@ ## Simple version comparison # -cmp_ver = lambda a, b, tol=1: {-1: '<', 0: '~', 1: '>'}[cmp((a-b)//tol, 0)] +cmp_ver = lambda a, b, tol=1: {-1: '<', 0: '~', 1: '>'}[cmp((a - b) // tol, 0)] def getfileversion(filename): @@ -172,7 +179,7 @@ if line.find('__version__') == 0: exec(line) break - stat = os.stat(fn) + stat = os.stat(fn) mtime = datetime.datetime.fromtimestamp(stat.st_mtime).isoformat(' ') if mtime and __version__: return u'%s %s %s' % (filename, __version__[5:-1][:7], mtime) -- To view, visit https://gerrit.wikimedia.org/r/81197 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0a82d5c2139fdcbe27be64a39f0647e6be9be700 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/compat Gerrit-Branch: master Gerrit-Owner: DrTrigon <dr.tri...@surfeu.ch> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits