From be36a1411c41376ab2eb774541578c5d596c45e0 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Mon, 10 Feb 2020 15:01:12 +0530 Subject: [PATCH 1/2] feat(bench update): allow pull-only update on specified apps * renamed method pull_all_apps to pull_apps * allow specifying a list of applications to be updated with: bench update --pull --apps frappe,erpnext * if no applications are specified, all apps present inside apps.txt will be pulled Signed-off-by: Chinmay D. Pai --- bench/app.py | 7 ++++--- bench/commands/update.py | 35 ++++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/bench/app.py b/bench/app.py index ea5d2a22..8321a577 100755 --- a/bench/app.py +++ b/bench/app.py @@ -197,13 +197,14 @@ def remove_app(app, bench_path='.'): if get_config(bench_path).get('restart_systemd_on_update'): restart_systemd_processes(bench_path=bench_path) -def pull_all_apps(bench_path='.', reset=False): +def pull_apps(apps=None, bench_path='.', reset=False): '''Check all apps if there no local changes, pull''' rebase = '--rebase' if get_config(bench_path).get('rebase_on_pull') else '' + apps = apps or get_apps(bench_path=bench_path) # chech for local changes if not reset: - for app in get_apps(bench_path=bench_path): + for app in apps: excluded_apps = get_excluded_apps() if app in excluded_apps: print("Skipping reset for app {}".format(app)) @@ -227,7 +228,7 @@ Here are your choices: sys.exit(1) excluded_apps = get_excluded_apps() - for app in get_apps(bench_path=bench_path): + for app in apps: if app in excluded_apps: print("Skipping pull for app {}".format(app)) continue diff --git a/bench/commands/update.py b/bench/commands/update.py index 82f857ba..e9093fd7 100755 --- a/bench/commands/update.py +++ b/bench/commands/update.py @@ -1,8 +1,9 @@ import click +import re import sys import os from bench.config.common_site_config import get_config, update_config -from bench.app import pull_all_apps, is_version_upgrade, validate_branch +from bench.app import pull_apps, is_version_upgrade, validate_branch from bench.utils import (update_bench, validate_upgrade, pre_upgrade, post_upgrade, before_update, update_requirements, update_node_packages, backup_all_sites, patch_sites, build_assets, restart_supervisor_processes, restart_systemd_processes, is_bench_directory) @@ -12,6 +13,7 @@ from six.moves import reload_module @click.command('update') @click.option('--pull', is_flag=True, help="Pull changes in all the apps in bench") +@click.option('--apps', type=str) @click.option('--patch', is_flag=True, help="Run migrations for all sites in the bench") @click.option('--build', is_flag=True, help="Build JS and CSS artifacts for the bench") @click.option('--bench', is_flag=True, help="Update bench") @@ -22,7 +24,7 @@ from six.moves import reload_module @click.option('--no-backup', is_flag=True) @click.option('--force', is_flag=True) @click.option('--reset', is_flag=True, help="Hard resets git branch's to their new states overriding any changes and overriding rebase on pull") -def update(pull=False, patch=False, build=False, bench=False, auto=False, restart_supervisor=False, restart_systemd=False, requirements=False, no_backup=False, force=False, reset=False): +def update(pull=False, apps=None, patch=False, build=False, bench=False, auto=False, restart_supervisor=False, restart_systemd=False, requirements=False, no_backup=False, force=False, reset=False): "Update bench" if not is_bench_directory(): @@ -39,16 +41,20 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar patches.run(bench_path='.') conf = get_config(".") + if apps and not pull: + apps = [] + if bench and conf.get('update_bench_on_update'): update_bench(bench_repo=True, requirements=False) restart_update({ - 'pull': pull, - 'patch': patch, - 'build': build, - 'requirements': requirements, - 'no-backup': no_backup, - 'restart-supervisor': restart_supervisor, - 'reset': reset + 'pull': pull, + 'apps': apps, + 'patch': patch, + 'build': build, + 'requirements': requirements, + 'no-backup': no_backup, + 'restart-supervisor': restart_supervisor, + 'reset': reset }) if conf.get('release_bench'): @@ -65,9 +71,9 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar print("This would take significant time to migrate and might break custom apps.") click.confirm('Do you want to continue?', abort=True) - _update(pull, patch, build, bench, auto, restart_supervisor, restart_systemd, requirements, no_backup, force=force, reset=reset) + _update(pull, apps, patch, build, bench, auto, restart_supervisor, restart_systemd, requirements, no_backup, force=force, reset=reset) -def _update(pull=False, patch=False, build=False, update_bench=False, auto=False, restart_supervisor=False, +def _update(pull=False, apps=None, patch=False, build=False, update_bench=False, auto=False, restart_supervisor=False, restart_systemd=False, requirements=False, no_backup=False, bench_path='.', force=False, reset=False): conf = get_config(bench_path=bench_path) version_upgrade = is_version_upgrade(bench_path=bench_path) @@ -84,8 +90,11 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False print('Backing up sites...') backup_all_sites(bench_path=bench_path) + if apps: + apps = [app for app in re.split(",| ", apps) if app] + if pull: - pull_all_apps(bench_path=bench_path, reset=reset) + pull_apps(apps=apps, bench_path=bench_path, reset=reset) if requirements: update_requirements(bench_path=bench_path) @@ -121,7 +130,7 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False @click.command('retry-upgrade') @click.option('--version', default=5) def retry_upgrade(version): - pull_all_apps() + pull_apps() patch_sites() build_assets() post_upgrade(version-1, version) From cab88313116c48f4531c8e6bdea30cc27832a8dd Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Tue, 24 Mar 2020 10:43:47 +0530 Subject: [PATCH 2/2] bumped to version 5.0.0 --- bench/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bench/__init__.py b/bench/__init__.py index e120c37b..1f0c5aac 100644 --- a/bench/__init__.py +++ b/bench/__init__.py @@ -1,6 +1,6 @@ from jinja2 import Environment, PackageLoader -__version__ = "4.1.0" +__version__ = "5.0.0" env = Environment(loader=PackageLoader('bench.config'))