Merge remote-tracking branch 'supybot/maint/0.83.4' into testing

Conflicts:
	sandbox/release.py
This commit is contained in:
Valentin Lorentz 2012-07-06 11:09:34 +02:00
commit 18dd017e99
5 changed files with 87 additions and 59 deletions

View File

@ -383,7 +383,8 @@ class Filter(callbacks.Plugin):
if c == ' ':
return c
if fg is None:
fg = str(random.randint(2, 15)).zfill(2)
fg = random.randint(2, 15)
fg = str(fg).zfill(2)
return '\x03%s%s' % (fg, c)
@internationalizeDocstring

View File

@ -4,6 +4,9 @@ import os
import re
import sys
import shutil
import subprocess
from optparse import OptionParser
def firstLines(filename, n):
fd = file(filename)
@ -11,6 +14,7 @@ def firstLines(filename, n):
while n:
n -= 1
lines.append(fd.readline().rstrip('\r\n'))
fd.close()
return lines
def firstLine(filename):
@ -20,62 +24,64 @@ def error(s):
sys.stderr.write(s+'\n')
sys.exit(-1)
def system(sh, errmsg=None):
def system(sh, errmsg=None, **kwargs):
if errmsg is None:
errmsg = repr(sh)
ret = os.system(sh)
if isinstance(sh, basestring):
errmsg = repr(sh)
else:
errmsg = repr(' '.join(sh))
ret = subprocess.call(sh, **kwargs)
if ret:
error(errmsg + ' (error code: %s)' % ret)
def usage():
error('Usage: %s [-s|-n] <sf username> <version>\nSpecify -s to pass it on '
'to the relevant git commands.\nSpecify -n to perform a dry-run '
'release. No commits or tags are pushed and no files are uploaded.'
'\nMust be called from a git checkout.'
% sys.argv[0])
def checkGitRepo():
system('test "$(git rev-parse --is-inside-work-tree)" = "true"',
'Must be run from a git checkout.')
'Must be run from a git checkout.',
shell=True)
system('test "$(git rev-parse --show-cdup >/dev/null)" = ""',
'Must be run from the top-level directory of the git checkout.')
'Must be run from the top-level directory of the git checkout.',
shell=True)
system('git rev-parse --verify HEAD >/dev/null '
'&& git update-index --refresh'
'&& git diff-files --quiet'
'&& git diff-index --cached --quiet HEAD --',
'Your tree is unclean. Can\'t run from here.')
'Your tree is unclean. Can\'t run from here.',
shell=True)
if __name__ == '__main__':
if len(sys.argv) < 3 or len(sys.argv) > 5:
usage()
usage = 'usage: %prog [options] <username> <version>'
parser = OptionParser(usage=usage)
parser.set_defaults(sign=False, verbose=False, branch='master')
parser.add_option('-s', '--sign', action='store_true', dest='sign',
help='Pass on -s to relevant git commands')
parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
help='Build the release, but do not push to the git '
'remote or upload the release archives.')
parser.add_option('-b', '--branch', metavar='BRANCH', dest='branch',
help='Branch to use for the release. Default: %default')
(options, args) = parser.parse_args()
if len(args) != 2:
parser.error('Both username and version must be specified')
(u, v) = args
if not re.match(r'^\d+\.\d+\.\d+(\.\d+)?\w*$', v):
parser.error('Invalid version string: '
'must be of the form MAJOR.MINOR.PATCHLEVEL')
checkGitRepo()
sign = ''
dryrun = False
while len(sys.argv) > 3:
if sys.argv[1] == '-s':
sign = '-s'
sys.argv.pop(1)
elif sys.argv[1] == '-n':
dryrun = True
sys.argv.pop(1)
else:
usage()
print 'Check version string for validity.'
(u, v) = sys.argv[1:]
if not re.match(r'^\d+\.\d+\.\d+(\.\d+)?\w*$', v):
error('Invalid version string: '
'must be of the form MAJOR.MINOR.PATCHLEVEL.')
sign = options.sign
dryrun = options.dry_run
branch = options.branch
if os.path.exists('supybot'):
error('I need to make the directory "supybot" but it already exists.'
' Change to an appropriate directory or remove the supybot '
'directory to continue.')
print 'Checking out fresh tree from git.'
system('git clone git+ssh://%s@supybot.git.sourceforge.net/gitroot/supybot'
% u)
repo = 'git+ssh://%s@supybot.git.sourceforge.net/gitroot/supybot/supybot' % u
system(['git', 'clone', '-b', branch, repo])
os.chdir('supybot')
print 'Checking RELNOTES version line.'
@ -90,38 +96,47 @@ if __name__ == '__main__':
error('Invalid third line in ChangeLog.')
print 'Updating version in version files.'
versionFiles = ('src/version.py')
versionFiles = ['src/version.py']
for fn in versionFiles:
sh = 'perl -pi -e "s/^version\s*=.*/version = \'%s\'/" %s' % (v, fn)
sh = ['perl', '-pi', '-e', 's/^version\s*=.*/version = \'%s\'/' % v, fn]
system(sh, 'Error changing version in %s' % fn)
system('git commit %s -m \'Updated to %s.\' %s'
% (sign, v, ' '.join(versionFiles)))
commit = ['git', 'commit']
if sign:
commit.append('-s')
system(commit + ['-m', 'Updated to %s.' % v] + versionFiles)
print 'Tagging release.'
system('git tag %s -m "Release %s" %s' % (sign or '-a', v, v))
tag = ['git', 'tag']
if sign:
tag.append('-s')
system(tag + ['-m', "Release %s" % v, 'v%s' % v])
print 'Committing %s+git to version files.' % v
for fn in versionFiles:
sh = 'perl -pi -e "s/^version\s*=.*/version = \'%s\'/" %s' % \
(v + '+git', fn)
system(sh, 'Error changing version in %s' % fn)
system('git commit %s -m \'Updated to %s+git.\' %s'
% (sign, v, ' '.join(versionFiles)))
system(['perl', '-pi', '-e',
's/^version\s*=.*/version = \'%s+git\'/' % v, fn],
'Error changing version in %s' % fn)
system(commit + ['-m', 'Updated to %s+git.' % v] + versionFiles)
if not dryrun:
print 'Pushing commits and tag.'
system('git push origin master')
system('git push --tags')
system(['git', 'push', 'origin', branch])
system(['git', 'push', '--tags'])
archive = ['git', 'archive', '--prefix=Supybot-%s/' % v]
print 'Creating tarball (gzip).'
system('git archive --prefix=Supybot-%s/ --format=tar %s '
'| gzip -c >../Supybot-%s.tar.gz' % (v, v, v))
system(archive + ['-o', '../Supybot-%s.tar.gz' % v,
'--format=tgz', 'v%s' % v])
system(['git', 'config', 'tar.bz2.command', 'bzip2 -c'])
print 'Creating tarball (bzip2).'
system('git archive --prefix=Supybot-%s/ --format=tar %s '
'| bzip2 -c >../Supybot-%s.tar.bz2' % (v, v, v))
system(archive + ['-o', '../Supybot-%s.tar.bz2' % v,
'--format=bz2', 'v%s' % v])
print 'Creating zip.'
system('git archive --prefix=Supybot-%s/ --format=zip %s '
'>../Supybot-%s.zip' % (v, v, v))
system(archive + ['-o', '../Supybot-%s.zip' % v,
'--format=zip', 'v%s' % v])
os.chdir('..')
shutil.rmtree('supybot')

View File

@ -49,6 +49,8 @@ import os
import subprocess
from src.version import version
plugins = [s for s in os.listdir('plugins') if
os.path.exists(os.path.join('plugins', s, 'plugin.py'))]
@ -154,7 +156,7 @@ setup(
name='supybot',
version=version,
author='Jeremy Fincher',
url='http://supybot.com/',
url='http://sourceforge.net/projects/supybot/',
author_email='jemfinch@supybot.com',
download_url='http://www.sf.net/project/showfiles.php?group_id=58965',
description='A flexible and extensible Python IRC bot and framework.',

View File

@ -412,11 +412,16 @@ class FormatParser(object):
i = 0
setI = False
c = self.getChar()
while c.isdigit() and i < 100:
setI = True
i *= 10
i += int(c)
c = self.getChar()
while c.isdigit():
j = i * 10
j += int(c)
if j >= 16:
self.ungetChar(c)
break
else:
setI = True
i = j
c = self.getChar()
self.ungetChar(c)
if setI:
return i
@ -428,6 +433,8 @@ class FormatParser(object):
c = self.getChar()
if c == ',':
context.bg = self.getInt()
else:
self.ungetChar(c)
def wrap(s, length):
processed = []

3
src/version.py Normal file
View File

@ -0,0 +1,3 @@
"""stick the various versioning attributes in here, so we only have to change
them once."""
version = '0.83.4.1+git'