mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 16:36:25 +00:00
[minor] removed upgrade command from switch-to-master and switch-to-develop (#484)
* [minor] remove --upgrade option from bench update * [minor] removed upgrade command from switch-to-master and switch-to-develop
This commit is contained in:
parent
e79d722f8c
commit
d1c73b20d0
@ -304,10 +304,10 @@ def switch_branch(branch, apps=None, bench_path='.', upgrade=False, check_upgrad
|
|||||||
def switch_to_branch(branch=None, apps=None, bench_path='.', upgrade=False):
|
def switch_to_branch(branch=None, apps=None, bench_path='.', upgrade=False):
|
||||||
switch_branch(branch, apps=apps, bench_path=bench_path, upgrade=upgrade)
|
switch_branch(branch, apps=apps, bench_path=bench_path, upgrade=upgrade)
|
||||||
|
|
||||||
def switch_to_master(apps=None, bench_path='.', upgrade=False):
|
def switch_to_master(apps=None, bench_path='.', upgrade=True):
|
||||||
switch_branch('master', apps=apps, bench_path=bench_path, upgrade=upgrade)
|
switch_branch('master', apps=apps, bench_path=bench_path, upgrade=upgrade)
|
||||||
|
|
||||||
def switch_to_develop(apps=None, bench_path='.', upgrade=False):
|
def switch_to_develop(apps=None, bench_path='.', upgrade=True):
|
||||||
switch_branch('develop', apps=apps, bench_path=bench_path, upgrade=upgrade)
|
switch_branch('develop', apps=apps, bench_path=bench_path, upgrade=upgrade)
|
||||||
|
|
||||||
def get_version_from_string(contents, field='__version__'):
|
def get_version_from_string(contents, field='__version__'):
|
||||||
|
@ -15,11 +15,10 @@ from bench import patches
|
|||||||
@click.option('--requirements',is_flag=True, help="Update requirements")
|
@click.option('--requirements',is_flag=True, help="Update requirements")
|
||||||
@click.option('--restart-supervisor',is_flag=True, help="restart supervisor processes after update")
|
@click.option('--restart-supervisor',is_flag=True, help="restart supervisor processes after update")
|
||||||
@click.option('--auto',is_flag=True)
|
@click.option('--auto',is_flag=True)
|
||||||
@click.option('--upgrade',is_flag=True, help="Required for major version updates")
|
|
||||||
@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, requirements=False, no_backup=False, upgrade=False, force=False, reset=False):
|
def update(pull=False, patch=False, build=False, bench=False, auto=False, restart_supervisor=False, requirements=False, no_backup=False, force=False, reset=False):
|
||||||
"Update bench"
|
"Update bench"
|
||||||
|
|
||||||
if not (pull or patch or build or bench or requirements):
|
if not (pull or patch or build or bench or requirements):
|
||||||
@ -40,7 +39,6 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
|
|||||||
'requirements': requirements,
|
'requirements': requirements,
|
||||||
'no-backup': no_backup,
|
'no-backup': no_backup,
|
||||||
'restart-supervisor': restart_supervisor,
|
'restart-supervisor': restart_supervisor,
|
||||||
'upgrade': upgrade,
|
|
||||||
'reset':reset
|
'reset':reset
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -48,29 +46,14 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
|
|||||||
print('Release bench, cannot update')
|
print('Release bench, cannot update')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
version_upgrade = is_version_upgrade()
|
_update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, force=force, reset=reset)
|
||||||
|
|
||||||
if version_upgrade[0] and not upgrade:
|
|
||||||
print()
|
|
||||||
print()
|
|
||||||
print("This update will cause a major version change in Frappe/ERPNext from {0} to {1}.".format(*version_upgrade[1:]))
|
|
||||||
print("This would take significant time to migrate and might break custom apps. Please run `bench update --upgrade` to confirm.")
|
|
||||||
print()
|
|
||||||
print("You can stay on the latest stable release by running `bench switch-to-master` or pin your bench to {0} by running `bench switch-to-v{0}`".format(version_upgrade[1]))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
_update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force, reset=reset)
|
|
||||||
|
|
||||||
|
|
||||||
def _update(pull=False, patch=False, build=False, update_bench=False, auto=False, restart_supervisor=False,
|
def _update(pull=False, patch=False, build=False, update_bench=False, auto=False, restart_supervisor=False,
|
||||||
requirements=False, no_backup=False, upgrade=False, bench_path='.', force=False, reset=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)
|
||||||
|
|
||||||
if version_upgrade[0] and not upgrade:
|
if version_upgrade[0] or (not version_upgrade[0] and force):
|
||||||
raise Exception("Major Version Upgrade")
|
|
||||||
|
|
||||||
if upgrade and (version_upgrade[0] or (not version_upgrade[0] and force)):
|
|
||||||
validate_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
|
validate_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
|
||||||
|
|
||||||
before_update(bench_path=bench_path, requirements=requirements)
|
before_update(bench_path=bench_path, requirements=requirements)
|
||||||
@ -82,7 +65,7 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False
|
|||||||
update_requirements(bench_path=bench_path)
|
update_requirements(bench_path=bench_path)
|
||||||
update_npm_packages(bench_path=bench_path)
|
update_npm_packages(bench_path=bench_path)
|
||||||
|
|
||||||
if upgrade and (version_upgrade[0] or (not version_upgrade[0] and force)):
|
if version_upgrade[0] or (not version_upgrade[0] and force):
|
||||||
pre_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
|
pre_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
|
||||||
import bench.utils, bench.app
|
import bench.utils, bench.app
|
||||||
print('Reloading bench...')
|
print('Reloading bench...')
|
||||||
@ -98,7 +81,7 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False
|
|||||||
patch_sites(bench_path=bench_path)
|
patch_sites(bench_path=bench_path)
|
||||||
if build:
|
if build:
|
||||||
build_assets(bench_path=bench_path)
|
build_assets(bench_path=bench_path)
|
||||||
if upgrade and (version_upgrade[0] or (not version_upgrade[0] and force)):
|
if version_upgrade[0] or (not version_upgrade[0] and force):
|
||||||
post_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
|
post_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
|
||||||
if restart_supervisor or conf.get('restart_supervisor_on_update'):
|
if restart_supervisor or conf.get('restart_supervisor_on_update'):
|
||||||
restart_supervisor_processes(bench_path=bench_path)
|
restart_supervisor_processes(bench_path=bench_path)
|
||||||
@ -108,7 +91,6 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False
|
|||||||
print("Open source depends on your contributions, so please contribute bug reports, patches, fixes or cash and be a part of the community")
|
print("Open source depends on your contributions, so please contribute bug reports, patches, fixes or cash and be a part of the community")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
@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):
|
||||||
@ -117,12 +99,10 @@ def retry_upgrade(version):
|
|||||||
build_assets()
|
build_assets()
|
||||||
post_upgrade(version-1, version)
|
post_upgrade(version-1, version)
|
||||||
|
|
||||||
|
|
||||||
def restart_update(kwargs):
|
def restart_update(kwargs):
|
||||||
args = ['--'+k for k, v in list(kwargs.items()) if v]
|
args = ['--'+k for k, v in list(kwargs.items()) if v]
|
||||||
os.execv(sys.argv[0], sys.argv[:2] + args)
|
os.execv(sys.argv[0], sys.argv[:2] + args)
|
||||||
|
|
||||||
|
|
||||||
@click.command('switch-to-branch')
|
@click.command('switch-to-branch')
|
||||||
@click.argument('branch')
|
@click.argument('branch')
|
||||||
@click.argument('apps', nargs=-1)
|
@click.argument('apps', nargs=-1)
|
||||||
@ -134,26 +114,20 @@ def switch_to_branch(branch, apps, upgrade=False):
|
|||||||
print('Switched to ' + branch)
|
print('Switched to ' + branch)
|
||||||
print('Please run `bench update --patch` to be safe from any differences in database schema')
|
print('Please run `bench update --patch` to be safe from any differences in database schema')
|
||||||
|
|
||||||
|
|
||||||
@click.command('switch-to-master')
|
@click.command('switch-to-master')
|
||||||
@click.option('--upgrade',is_flag=True)
|
def switch_to_master():
|
||||||
def switch_to_master(upgrade=False):
|
|
||||||
"Switch frappe and erpnext to master branch"
|
"Switch frappe and erpnext to master branch"
|
||||||
from bench.app import switch_to_master
|
from bench.app import switch_to_master
|
||||||
switch_to_master(upgrade=upgrade, apps=['frappe', 'erpnext'])
|
switch_to_master(apps=['frappe', 'erpnext'])
|
||||||
print()
|
print()
|
||||||
print('Switched to master')
|
print('Switched to master')
|
||||||
print('Please run `bench update --patch` to be safe from any differences in database schema')
|
print('Please run `bench update --patch` to be safe from any differences in database schema')
|
||||||
|
|
||||||
|
|
||||||
@click.command('switch-to-develop')
|
@click.command('switch-to-develop')
|
||||||
@click.option('--upgrade',is_flag=True)
|
|
||||||
def switch_to_develop(upgrade=False):
|
def switch_to_develop(upgrade=False):
|
||||||
"Switch frappe and erpnext to develop branch"
|
"Switch frappe and erpnext to develop branch"
|
||||||
from bench.app import switch_to_develop
|
from bench.app import switch_to_develop
|
||||||
switch_to_develop(upgrade=upgrade, apps=['frappe', 'erpnext'])
|
switch_to_develop(apps=['frappe', 'erpnext'])
|
||||||
print()
|
print()
|
||||||
print('Switched to develop')
|
print('Switched to develop')
|
||||||
print('Please run `bench update --patch` to be safe from any differences in database schema')
|
print('Please run `bench update --patch` to be safe from any differences in database schema')
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user