mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 09:02:10 +00:00
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 <chinmaydpai@gmail.com>
This commit is contained in:
parent
c8fa035e4c
commit
be36a1411c
@ -197,13 +197,14 @@ def remove_app(app, bench_path='.'):
|
|||||||
if get_config(bench_path).get('restart_systemd_on_update'):
|
if get_config(bench_path).get('restart_systemd_on_update'):
|
||||||
restart_systemd_processes(bench_path=bench_path)
|
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'''
|
'''Check all apps if there no local changes, pull'''
|
||||||
rebase = '--rebase' if get_config(bench_path).get('rebase_on_pull') else ''
|
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
|
# chech for local changes
|
||||||
if not reset:
|
if not reset:
|
||||||
for app in get_apps(bench_path=bench_path):
|
for app in apps:
|
||||||
excluded_apps = get_excluded_apps()
|
excluded_apps = get_excluded_apps()
|
||||||
if app in excluded_apps:
|
if app in excluded_apps:
|
||||||
print("Skipping reset for app {}".format(app))
|
print("Skipping reset for app {}".format(app))
|
||||||
@ -227,7 +228,7 @@ Here are your choices:
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
excluded_apps = get_excluded_apps()
|
excluded_apps = get_excluded_apps()
|
||||||
for app in get_apps(bench_path=bench_path):
|
for app in apps:
|
||||||
if app in excluded_apps:
|
if app in excluded_apps:
|
||||||
print("Skipping pull for app {}".format(app))
|
print("Skipping pull for app {}".format(app))
|
||||||
continue
|
continue
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import click
|
import click
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from bench.config.common_site_config import get_config, update_config
|
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,
|
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,
|
update_requirements, update_node_packages, backup_all_sites, patch_sites, build_assets,
|
||||||
restart_supervisor_processes, restart_systemd_processes, is_bench_directory)
|
restart_supervisor_processes, restart_systemd_processes, is_bench_directory)
|
||||||
@ -12,6 +13,7 @@ from six.moves import reload_module
|
|||||||
|
|
||||||
@click.command('update')
|
@click.command('update')
|
||||||
@click.option('--pull', is_flag=True, help="Pull changes in all the apps in bench")
|
@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('--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('--build', is_flag=True, help="Build JS and CSS artifacts for the bench")
|
||||||
@click.option('--bench', is_flag=True, help="Update 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('--no-backup', is_flag=True)
|
||||||
@click.option('--force', 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")
|
@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"
|
"Update bench"
|
||||||
|
|
||||||
if not is_bench_directory():
|
if not is_bench_directory():
|
||||||
@ -39,10 +41,14 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
|
|||||||
patches.run(bench_path='.')
|
patches.run(bench_path='.')
|
||||||
conf = get_config(".")
|
conf = get_config(".")
|
||||||
|
|
||||||
|
if apps and not pull:
|
||||||
|
apps = []
|
||||||
|
|
||||||
if bench and conf.get('update_bench_on_update'):
|
if bench and conf.get('update_bench_on_update'):
|
||||||
update_bench(bench_repo=True, requirements=False)
|
update_bench(bench_repo=True, requirements=False)
|
||||||
restart_update({
|
restart_update({
|
||||||
'pull': pull,
|
'pull': pull,
|
||||||
|
'apps': apps,
|
||||||
'patch': patch,
|
'patch': patch,
|
||||||
'build': build,
|
'build': build,
|
||||||
'requirements': requirements,
|
'requirements': requirements,
|
||||||
@ -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.")
|
print("This would take significant time to migrate and might break custom apps.")
|
||||||
click.confirm('Do you want to continue?', abort=True)
|
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):
|
restart_systemd=False, requirements=False, no_backup=False, bench_path='.', force=False, reset=False):
|
||||||
conf = get_config(bench_path=bench_path)
|
conf = get_config(bench_path=bench_path)
|
||||||
version_upgrade = is_version_upgrade(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...')
|
print('Backing up sites...')
|
||||||
backup_all_sites(bench_path=bench_path)
|
backup_all_sites(bench_path=bench_path)
|
||||||
|
|
||||||
|
if apps:
|
||||||
|
apps = [app for app in re.split(",| ", apps) if app]
|
||||||
|
|
||||||
if pull:
|
if pull:
|
||||||
pull_all_apps(bench_path=bench_path, reset=reset)
|
pull_apps(apps=apps, bench_path=bench_path, reset=reset)
|
||||||
|
|
||||||
if requirements:
|
if requirements:
|
||||||
update_requirements(bench_path=bench_path)
|
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.command('retry-upgrade')
|
||||||
@click.option('--version', default=5)
|
@click.option('--version', default=5)
|
||||||
def retry_upgrade(version):
|
def retry_upgrade(version):
|
||||||
pull_all_apps()
|
pull_apps()
|
||||||
patch_sites()
|
patch_sites()
|
||||||
build_assets()
|
build_assets()
|
||||||
post_upgrade(version-1, version)
|
post_upgrade(version-1, version)
|
||||||
|
Loading…
Reference in New Issue
Block a user