diff options
Diffstat (limited to 'Build/source/texk/gregorio/gregorio-src/VersionManager.py')
-rw-r--r-- | Build/source/texk/gregorio/gregorio-src/VersionManager.py | 211 |
1 files changed, 186 insertions, 25 deletions
diff --git a/Build/source/texk/gregorio/gregorio-src/VersionManager.py b/Build/source/texk/gregorio/gregorio-src/VersionManager.py index f1676fceaf8..7a7c19edb5d 100644 --- a/Build/source/texk/gregorio/gregorio-src/VersionManager.py +++ b/Build/source/texk/gregorio/gregorio-src/VersionManager.py @@ -5,7 +5,7 @@ See VersionUpdate.py -h for help - Copyright (C) 2015-2017 The Gregorio Project (see CONTRIBUTORS.md) + Copyright (C) 2015-2018 The Gregorio Project (see CONTRIBUTORS.md) This file is part of Gregorio. @@ -32,6 +32,7 @@ import subprocess import time import os import locale +import linecache from datetime import date from distutils.util import strtobool @@ -41,7 +42,9 @@ locale.setlocale(locale.LC_TIME, 'C') os.chdir(sys.path[0]) VERSION_FILE = '.gregorio-version' +CURRENTYEAR = str(date.today().year) GREGORIO_FILES = ["configure.ac", + "ctan-o-mat.config", "windows/gregorio-resources.rc", "macosx/Gregorio.pkgproj", "macosx/douninstall.sh", @@ -64,6 +67,106 @@ GREGORIO_FILES = ["configure.ac", "tex/gregoriotex-common.tex", "fonts/squarize.py", ] +COPYRIGHT_FILES = ["install-gtex.sh", + "build-ctan.sh", + "ctan_upload.sh", + "tex/gregoriotex-signs.tex", + "tex/gregorio-vowels.dat", + "tex/gsp-default.tex", + "tex/gregoriotex-nabc.lua", + "tex/gregoriotex-symbols.lua", + "tex/gregoriotex-chars.tex", + "tex/gregoriotex-main.tex", + "tex/gregoriotex-spaces.tex", + "tex/Makefile.am", + "tex/gregoriotex-common.tex", + "tex/gregoriotex-syllable.tex", + "tex/gregoriotex.lua", + "tex/gregoriotex.sty", + "tex/gregoriosyms.sty", + "tex/gregoriotex-nabc.tex", + "tex/gregoriotex.tex", + "tex/gregoriotex-signs.lua", + "tex/gregoriotex-symbols.tex", + "contrib/TeXShop/Makefile.am", + "contrib/900_gregorio.xml", + "contrib/Makefile.am", + "contrib/gabc.lang", + "contrib/gprocess", + "contrib/checkSyllabation.py", + "configure.ac", + "examples/Makefile.am", + "Makefile.am", + "install.sh", + "debian/copyright", + "debian/manpage.xml", + "doc/Command_Index_User.tex", + "doc/Makefile.am", + "doc/GregorioRef.tex", + "doc/Command_Index_gregorio.tex", + "doc/Command_Index_internal.tex", + "doc/GregorioNabcRef.tex", + "doc/Gabc.tex", + "doc/GregorioRef.lua", + "doc/Appendix_Font_Tables.tex", + "VersionManager.py", + "coverage.sh", + "COPYING.md", + "src/characters.h", + "src/plugins.h", + "src/gregoriotex/gregoriotex-write.c", + "src/gregoriotex/gregoriotex.h", + "src/gregoriotex/gregoriotex-position.c", + "src/unicode.c", + "src/unicode.h", + "src/messages.h", + "src/support.c", + "src/sha1.h", + "src/messages.c", + "src/support.h", + "src/sha1.c", + "src/struct.h", + "src/bool.h", + "src/struct_iter.h", + "src/Makefile.am", + "src/dump/dump.c", + "src/encode_utf8strings.c", + "src/enum_generator.h", + "src/gabc/gabc-score-determination.c", + "src/gabc/gabc-elements-determination.c", + "src/gabc/gabc-write.c", + "src/gabc/gabc-notes-determination.l", + "src/gabc/gabc.h", + "src/gabc/gabc-score-determination.l", + "src/gabc/gabc-score-determination.y", + "src/gabc/gabc-score-determination.h", + "src/gabc/gabc-glyphs-determination.c", + "src/utf8strings.h.in", + "src/config.h", + "src/characters.c", + "src/vowel/vowel-rules.y", + "src/vowel/vowel.h", + "src/vowel/vowel-rules.h", + "src/vowel/vowel-rules.l", + "src/vowel/vowel.c", + "src/gregorio-utils.c", + "src/struct.c", + "fonts/gregorio-base.sfd", + "fonts/granapadano-base.sfd", + "fonts/squarize.py", + "fonts/convertsfdtottf.py", + "fonts/Makefile.am", + "fonts/simplify.py", + "fonts/stemsschemas.py", + "fonts/greciliae-base.sfd", + "fonts/gregall.sfd", + "fonts/grelaon.sfd", + "fonts/gresgmodern.sfd", + "fonts/install_supp_fonts.lua", + "windows/gregorio.iss", + "windows/install.lua", + "windows/uninstall.lua", + ] def get_parser(): "Return command line parser" @@ -118,7 +221,7 @@ class Version(object): def __init__(self, versionfile): self.versionfile = versionfile - self.version = self.read_version() + self.version = linecache.getline(self.versionfile, 1).strip('\n') self.filename_version = self.filename_version_from_version(self.version) self.short_tag = None self.date = None @@ -130,19 +233,13 @@ class Version(object): def binary_version_from_version(self, version): "Return binary version number for Windows FILEVERSION" - bin = version.replace('.',',') - if '-' in bin: - bin = bin.replace('-beta',',1') - bin = bin.replace('-rc',',2') + binary = version.replace('.', ',') + if '-' in binary: + binary = binary.replace('-beta', ',1') + binary = binary.replace('-rc', ',2') else: - bin += ',30' - return bin - - def read_version(self): - "Return version for instance variable" - with open(self.versionfile, 'r') as verfile: - self.grever = verfile.readline() - return self.grever.strip('\n') + binary += ',30' + return binary def fetch_version(self): "Prints version" @@ -172,7 +269,7 @@ class Version(object): print('Updating {0} with the new version: {1}\n'.format( self.versionfile, self.version)) with open(self.versionfile, 'w') as verfile: - verfile.write(self.version) + verfile.write('{0}\n{1}'.format(self.version, CURRENTYEAR)) verfile.write('\n\n*** Do not modify this file. ***\n') verfile.write('Use VersionManager.py to change the version.\n') @@ -222,20 +319,48 @@ def replace_version(version_obj): result.append(line) with open(myfile, 'w') as outfile: outfile.write(''.join(result)) + sys.exit(0) + +def update_changelog(newver,upgradetype): + today = date.today() with open('CHANGELOG.md', 'r') as infile: result = [] + develop = False for line in infile: - if '[Unreleased][unreleased]' in line: - result.append(line) - result.append('\n') - result.append('\n') - newline = '## [' + newver + '] - ' + today.strftime("%Y-%m-%d") + '\n' - result.append(newline) + if upgradetype == "patch": + if '[Unreleased][develop]' in line: + print("Found an unreleased develop section.") + print("Patch releases should be based on ctan branch.") + sys.exit(1) + if '[Unreleased][CTAN]' in line: + result.append(line) + result.append('\n') + result.append('\n') + newline = '## [' + newver + '] - ' + today.strftime("%Y-%m-%d") + '\n' + result.append(newline) + else: + result.append(line) else: - result.append(line) - with open('CHANGELOG.md','w') as outfile: + if '[Unreleased][develop]' in line: + develop = True + result.append(line) + result.append('\n') + result.append('\n') + result.append('## [Unreleased][CTAN]\n') + result.append('\n') + result.append('\n') + newline = '## [' + newver + '] - ' + today.strftime("%Y-%m-%d") + '\n' + result.append(newline) + elif '[Unreleased][CTAN]' in line and develop: + continue + else: + result.append(line) + if not develop and upgradetype != "patch": + print("I didn't find a unreleased develop section.") + print("Non-patch releases should be based on develop branch.") + sys.exit(1) + with open('CHANGELOG.md', 'w') as outfile: outfile.write(''.join(result)) - sys.exit(0) def confirm_replace(oldver, newver): "Query the user to confirm action" @@ -262,6 +387,7 @@ def release_candidate(version_obj, not_interactive): newversion = re.sub(r'-.*', '-rc1', oldversion) if (not not_interactive): confirm_replace(oldversion, newversion) + update_changelog(newversion,"releasecandidate") version_obj.update_version(newversion) replace_version(version_obj) @@ -277,6 +403,7 @@ def beta(version_obj, not_interactive): sys.exit(1) if (not not_interactive): confirm_replace(oldversion, newversion) + update_changelog(newversion,"beta") version_obj.update_version(newversion) replace_version(version_obj) @@ -287,6 +414,7 @@ def bump_major(version_obj, not_interactive): newversion = str(int(nums.group(1)) +1) + '.0.0-beta1' if (not not_interactive): confirm_replace(oldversion, newversion) + update_changelog(newversion,"major") version_obj.update_version(newversion) replace_version(version_obj) @@ -297,6 +425,7 @@ def bump_minor(version_obj, not_interactive): newversion = nums.group(1) + str(int(nums.group(2)) +1) + '.0-beta1' if (not not_interactive): confirm_replace(oldversion, newversion) + update_changelog(newversion,"minor") version_obj.update_version(newversion) replace_version(version_obj) @@ -307,6 +436,7 @@ def bump_patch(version_obj, not_interactive): newversion = nums.group(1) + str(int(nums.group(2)) +1) if (not not_interactive): confirm_replace(oldversion, newversion) + update_changelog(newversion,"patch") version_obj.update_version(newversion) replace_version(version_obj) @@ -319,6 +449,7 @@ def set_manual_version(version_obj, user_version, not_interactive): newversion = user_version if (not not_interactive): confirm_replace(oldversion, newversion) + update_changelog(newversion,"manual") version_obj.update_version(newversion) replace_version(version_obj) @@ -328,9 +459,38 @@ def do_release(version_obj, not_interactive): newversion = re.sub(r'([\d.]+)-?.*', r'\1', oldversion) if (not not_interactive): confirm_replace(oldversion, newversion) + update_changelog(newversion,"release") version_obj.update_version(newversion) replace_version(version_obj) +def copyright_year(): + "Check and update copyright year as needed" + fileyear = linecache.getline(VERSION_FILE, 2).strip() + def year_range(matchobj): + "Check and add a year range to the copyright" + if matchobj.group(1) is not None: + return re.sub(fileyear, CURRENTYEAR, matchobj.group(0)) + return re.sub(fileyear, fileyear+'-'+CURRENTYEAR, matchobj.group(0)) + + if int(fileyear) != int(CURRENTYEAR): + print('Updating copyright year.') + for myfile in COPYRIGHT_FILES: + result = [] + with open(myfile, 'r') as infile: + for line in infile: + if re.search(r'[C|c]opyright.*Gregorio Project', line): + result.append(re.sub(r'(\d{4}-)?(\d{4})', year_range, line)) + elif re.search(r'[C|c]opyright.*Elie Roux', line): + result.append(re.sub(r'(\d{4}-)?(\d{4})', year_range, line)) + elif re.search(r'[C|c]opyright.*Richard Chonak', line): + result.append(re.sub(r'(\d{4}-)?(\d{4})', year_range, line)) + elif re.search(r'[C|c]opyright.*Jakub Jelinek', line): + result.append(re.sub(r'(\d{4}-)?(\d{4})', year_range, line)) + else: + result.append(line) + with open(myfile, 'w') as outfile: + outfile.write(''.join(result)) + def main(): "Main function" parser = get_parser() @@ -348,7 +508,8 @@ def main(): gregorio_version.fetch_version_debian_stable() elif args.get_debian_git: gregorio_version.fetch_version_debian_git() - elif args.beta: + copyright_year() + if args.beta: beta(gregorio_version, not_interactive) elif args.major: bump_major(gregorio_version, not_interactive) |