From d5011092f98dd28081f79e82bb85c2af5669a703 Mon Sep 17 00:00:00 2001 From: Renaud Le Gac <renaud.legac@free.fr> Date: Sat, 28 Jan 2012 23:19:18 +0100 Subject: [PATCH] Polish the argument of the buildVersion script. --- buildVersion.py | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/buildVersion.py b/buildVersion.py index f1cca7b6..cae3afb4 100755 --- a/buildVersion.py +++ b/buildVersion.py @@ -107,11 +107,11 @@ def git(): subprocess.call(cmd) -def update(version): - """Update version identifier in CHANGELOG and appbase.js +def set_version(version): + """Set version identifier in CHANGELOG and appbase.js """ - print 'Modified', JSBASE + print 'Set version in', JSBASE s = open(JSBASE, 'rb').read() # look for a pattern App.version = '0.8.3'; in appbase.js @@ -132,7 +132,7 @@ def update(version): # look for a pattern HEAD in the CHANGELOG # split the the string in 2 parts (pre HEAD, post HEAD) - print 'Modified', CHANGELOG + print 'Set version in', CHANGELOG s = open(CHANGELOG, 'rb').read() m = re.match("(.+HEAD\n)(.*)", s, re.DOTALL) @@ -201,10 +201,15 @@ if __name__ == '__main__': action="store_true", dest= "git", help= "run the git steps.") + + ops.add_option("-r", "--release", + action="store_true", + dest= "get", + help= "run the version of the current release and exit.") - ops.add_option("-u", "--update", + ops.add_option("-s", "--set_version", action="store_true", - dest= "update", + dest= "set", help= "run the update version step.") ops.add_option("-y", "--yuicompressor", @@ -218,16 +223,23 @@ if __name__ == '__main__': help= "run the web2py step.") ops.set_defaults(clean=False, + get=False, git=False, - update=False, + set=False, yuicompressor=False, web2py=False) (opt, args) = ops.parse_args() + # the version of the current release + if opt.get: + version = get_version() + print "\nThe version of the current release is %s\n" % version + sys.exit(0) + # by default run all steps: update, git, YUIcompressor and web2py - if not (opt.update or opt.git or opt.yuicompressor or opt.web2py): - opt.update = True + if not (opt.set or opt.git or opt.yuicompressor or opt.web2py): + opt.set = True opt.git = True opt.yuicompressor = True opt.web2py = True @@ -239,14 +251,14 @@ if __name__ == '__main__': clean() sys.exit(0) - if opt.update: + if opt.set: if args: version = args[0] else: version = raw_input('Enter the version identifier: ') - update(version) + set_version(version) if opt.yuicompressor: yuicompressor() if opt.git: git() -- GitLab