Merge pull request #728 from aaether32323/improve_release_py_renaming

release.py | Fix handling of files that are not in subdirs, and other minor changes.
This commit is contained in:
cyian-1756 2018-06-22 23:20:09 -04:00 committed by GitHub
commit c7dfc51160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,25 +37,24 @@ def isJar(filename):
# false if not # false if not
def isValidCommitMessage(message): def isValidCommitMessage(message):
if debug: if debug:
print("Checking if {} matchs pattern ^\d+\.\d+\.\d+:".format(message)) print(r"Checking if {} matches pattern ^\d+\.\d+\.\d+:".format(message))
pattern = re.compile("^\d+\.\d+\.\d+:") pattern = re.compile(r"^\d+\.\d+\.\d+:")
return re.match(pattern, message) return re.match(pattern, message)
# Checks if the update has the name ripme.jar, if not it renames the file # Checks if the update has the name ripme.jar, if not it renames the file
# Returns the update file path def checkAndRenameFile(path):
# TODO handle files that aren't in sub dirs """Check if path (a string) points to a ripme.jar. Returns the possibly renamed file path"""
def renameFile(path):
if not path.endswith("ripme.jar"): if not path.endswith("ripme.jar"):
print("Specified file is not named ripme.jar, renaming") print("Specified file is not named ripme.jar, renaming")
# os.sep is the path separator for the os this is being run on new_path = os.path.join(os.path.dirname(path), "ripme.jar")
os.rename(path, path.split(os.sep)[0] + os.sep + "ripme.jar") os.rename(path, new_path)
return path.split(os.sep)[0] + os.sep + "ripme.jar" return new_path
return path return path
ripmeJson = json.loads(open("ripme.json").read()) ripmeJson = json.loads(open("ripme.json").read())
fileToUploadPath = renameFile(args.file) fileToUploadPath = checkAndRenameFile(args.file)
InNoninteractiveMode = args.non_interactive InNoninteractiveMode = args.non_interactive
commitMessage = ripmeJson.get("changeList")[0] commitMessage = ripmeJson.get("changeList")[0]
releaseVersion = ripmeJson.get("latestVersion") releaseVersion = ripmeJson.get("latestVersion")