From 14302f83d755d2319a00db123dab14b300c8c93f Mon Sep 17 00:00:00 2001 From: Vladislav Date: Sun, 8 Oct 2017 21:48:26 +0300 Subject: [PATCH 1/2] Add python patch script --- patch.py | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 patch.py diff --git a/patch.py b/patch.py new file mode 100644 index 00000000..c8186d98 --- /dev/null +++ b/patch.py @@ -0,0 +1,56 @@ +import json +import subprocess + +# This script will: +# - read current version +# - increment patch version +# - update version in a few places +# - insert new line in ripme.json with message + +message = raw_input('message: ') + +with open('ripme.json') as dataFile: + ripmeJson = json.load(dataFile) +currentVersion = ripmeJson["latestVersion"] + +print 'Current version ' + currentVersion + +versionFields = currentVersion.split('.') +patchCur = int(versionFields[2]) +patchNext = patchCur + 1 +majorMinor = versionFields[:2] +majorMinor.append(str(patchNext)) +nextVersion = '.'.join(majorMinor) + +print 'Updating to ' + nextVersion + +substrExpr = 's/' + currentVersion + '/' + nextVersion + '/' +subprocess.call(['sed', '-i', '-e', substrExpr, 'src/main/java/com/rarchives/ripme/ui/UpdateUtils.java']) +subprocess.call(['git', 'grep', 'DEFAULT_VERSION.*' + nextVersion, + 'src/main/java/com/rarchives/ripme/ui/UpdateUtils.java']) + +substrExpr = 's/\\\"latestVersion\\\": \\\"' + currentVersion + '\\\"/\\\"latestVersion\\\": \\\"' +\ + nextVersion + '\\\"/' +subprocess.call(['sed', '-i', '-e', substrExpr, 'ripme.json']) +subprocess.call(['git', 'grep', 'latestVersion', 'ripme.json']) + +substrExpr = 's/' + currentVersion + '/' + nextVersion + '/' +subprocess.call(['sed', '-i', '-e', substrExpr, 'pom.xml']) +subprocess.call(['git', 'grep', '' + nextVersion + '', 'pom.xml']) + +commitMessage = nextVersion + ': ' + message +changeLogLine = ' \"' + commitMessage + '\",\n' + +dataFile = open("ripme.json", "r") +ripmeJsonLines = dataFile.readlines() +ripmeJsonLines.insert(3, changeLogLine) +outputContent = ''.join(ripmeJsonLines) +dataFile.close() + +dataFile = open("ripme.json", "w") +dataFile.write(outputContent) +dataFile.close() + +subprocess.call(['git', 'add', '-u']) +subprocess.call(['git', 'commit', '-m', commitMessage]) +subprocess.call(['git', 'tag', nextVersion]) From 864b68c8cf6fb655ca6c590195e165adf668ba7e Mon Sep 17 00:00:00 2001 From: Vladislav Date: Sun, 8 Oct 2017 22:38:50 +0300 Subject: [PATCH 2/2] Update patch.py --- patch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patch.py b/patch.py index c8186d98..b836f72b 100644 --- a/patch.py +++ b/patch.py @@ -7,13 +7,13 @@ import subprocess # - update version in a few places # - insert new line in ripme.json with message -message = raw_input('message: ') +message = input('message: ') with open('ripme.json') as dataFile: ripmeJson = json.load(dataFile) currentVersion = ripmeJson["latestVersion"] -print 'Current version ' + currentVersion +print ('Current version ' + currentVersion) versionFields = currentVersion.split('.') patchCur = int(versionFields[2]) @@ -22,7 +22,7 @@ majorMinor = versionFields[:2] majorMinor.append(str(patchNext)) nextVersion = '.'.join(majorMinor) -print 'Updating to ' + nextVersion +print ('Updating to ' + nextVersion) substrExpr = 's/' + currentVersion + '/' + nextVersion + '/' subprocess.call(['sed', '-i', '-e', substrExpr, 'src/main/java/com/rarchives/ripme/ui/UpdateUtils.java'])