jenkins-bot has submitted this change and it was merged.
Change subject: version.py: Accept 'gerrit' as remote name as well as 'origin' ......................................................................
version.py: Accept 'gerrit' as remote name as well as 'origin'
This code is awful. :(
Change-Id: I0f5f1d68d686fdbfe90393ae93ebaff9cd11ffe6 --- M pywikibot/version.py 1 file changed, 12 insertions(+), 5 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/version.py b/pywikibot/version.py index 0b6350f..cea522f 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -144,11 +144,18 @@ cmd = 'git.cmd'
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] - t = tag.strip().split('/') - tag = '[%s] %s' % (t[0][:-1], '-'.join(t[3:])) + # Try 'origin' and then 'gerrit' as remote name; bail if can't find either. + remote_pos = tag.find('[remote "origin"]') + if remote_pos == -1: + remote_pos = tag.find('[remote "gerrit"]') + if remote_pos == -1: + tag = '?' + else: + s = tag.find('url = ', ) + e = tag.find('\n', s) + tag = tag[(s + 6):e] + t = tag.strip().split('/') + tag = '[%s] %s' % (t[0][:-1], '-'.join(t[3:])) info = subprocess.Popen([cmd, '--no-pager', 'log', '-1', '--pretty=format:"%ad|%an|%h|%H|%d"'
pywikibot-commits@lists.wikimedia.org