diff --git a/scripts/base.py b/scripts/base.py index 887be16..f15512c 100644 --- a/scripts/base.py +++ b/scripts/base.py @@ -70,6 +70,9 @@ def print_info(info=""): print("------------------------------------------") return +def print_error(error=""): + print("\033[91m" + error + "\033[0m") + def print_list(list): print('[%s]' % ', '.join(map(str, list))) return @@ -413,6 +416,38 @@ def get_repositories(): result["core-fonts"] = [False, False] return result +def create_pull_request(branches_to, repo, is_no_errors=False, is_current_dir=False): + print("[git] create pull request: " + repo) + url = "https://github.com/ONLYOFFICE/" + repo + ".git" + if config.option("git-protocol") == "ssh": + url = "git@github.com:ONLYOFFICE/" + repo + ".git" + folder = get_script_dir() + "/../../" + repo + if is_current_dir: + folder = repo + is_not_exit = False + if not is_dir(folder): + retClone = cmd("git", ["clone", url, folder], is_no_errors) + if retClone != 0: + return + is_not_exit = True + old_cur = os.getcwd() + os.chdir(folder) + cmd("git", ["checkout", "-f", config.option("branch")], is_no_errors) + cmd("git", ["pull"], is_no_errors) + for branch_to in branches_to: + if "" != run_command("git log origin/" + branch_to + "..origin/" + config.option("branch"))["stdout"]: + cmd("git", ["checkout", "-f", branch_to], is_no_errors) + cmd("git", ["pull"], is_no_errors) + cmd("hub", ["pull-request", "--force", "--base", branch_to, "--head", config.option("branch"), "--no-edit"], is_no_errors) + if 0 != cmd("git", ["merge", "origin/" + config.option("branch"), "--no-ff", "--no-edit"], is_no_errors): + print_error("[git] Conflicts merge " + "origin/" + config.option("branch") + " to " + branch_to + " in repo " + url) + cmd("git", ["merge", "--abort"], is_no_errors) + else: + cmd("git", ["push"], is_no_errors) + + os.chdir(old_cur) + return + def update_repositories(repositories): for repo in repositories: value = repositories[repo] diff --git a/scripts/develop/release.py b/scripts/develop/release.py new file mode 100644 index 0000000..7057f30 --- /dev/null +++ b/scripts/develop/release.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +import sys +sys.path.append('../') + +import base +import dependence +import config + +branch_from = '' +branches_to = [] + +platform = base.host_platform() +if ("windows" == platform): + dependence.check_pythonPath() + dependence.check_gitPath() + +base.cmd_in_dir('../../', 'python', ['configure.py', '--branding', 'onlyoffice', '--branding-url', 'https://github.com/ONLYOFFICE/onlyoffice.git', '--branch', branch_from, '--module', 'server', '--update', '1', '--update-light', '1', '--clean', '0']) + +# parse configuration +config.parse() + +base.git_update('onlyoffice') + +# correct defaults (the branding repo is already updated) +config.parse_defaults() + +repositories = base.get_repositories() +base.update_repositories(repositories) + +#for repo in repositories +# base.create_pull_request(branches_to, repo, True) + +sys.exit(0)