mirror of
https://github.com/frappe/bench.git
synced 2024-11-11 15:51:03 +00:00
[feature] add reset option to update (#343)
* [feature] add reset option to update * fix for restarting update
This commit is contained in:
parent
6ad8d9b3f8
commit
cd877e19cc
12
bench/app.py
12
bench/app.py
@ -128,7 +128,8 @@ def remove_app(app, bench_path='.'):
|
||||
restart_supervisor_processes(bench_path=bench_path)
|
||||
|
||||
|
||||
def pull_all_apps(bench_path='.'):
|
||||
def pull_all_apps(bench_path='.',reset=False):
|
||||
|
||||
rebase = '--rebase' if get_config(bench_path).get('rebase_on_pull') else ''
|
||||
|
||||
for app in get_apps(bench_path=bench_path):
|
||||
@ -136,8 +137,13 @@ def pull_all_apps(bench_path='.'):
|
||||
if os.path.exists(os.path.join(app_dir, '.git')):
|
||||
remote = get_remote(app)
|
||||
logger.info('pulling {0}'.format(app))
|
||||
exec_cmd("git pull {rebase} {remote} {branch}".format(rebase=rebase,
|
||||
remote=remote, branch=get_current_branch(app, bench_path=bench_path)), cwd=app_dir)
|
||||
if reset:
|
||||
exec_cmd("git fetch --all", cwd=app_dir)
|
||||
exec_cmd("git reset --hard {remote}/{branch}".format(
|
||||
remote=remote, branch=get_current_branch(app,bench_path=bench_path)), cwd=app_dir)
|
||||
else:
|
||||
exec_cmd("git pull {rebase} {remote} {branch}".format(rebase=rebase,
|
||||
remote=remote, branch=get_current_branch(app, bench_path=bench_path)), cwd=app_dir)
|
||||
exec_cmd('find . -name "*.pyc" -delete', cwd=app_dir)
|
||||
|
||||
|
||||
|
@ -15,10 +15,11 @@ from bench import patches
|
||||
@click.option('--requirements',is_flag=True, help="Update requirements")
|
||||
@click.option('--restart-supervisor',is_flag=True, help="restart supervisor processes after update")
|
||||
@click.option('--auto',is_flag=True)
|
||||
@click.option('--upgrade',is_flag=True)
|
||||
@click.option('--upgrade',is_flag=True, help="Required for major version updates")
|
||||
@click.option('--no-backup',is_flag=True)
|
||||
@click.option('--force',is_flag=True)
|
||||
def update(pull=False, patch=False, build=False, bench=False, auto=False, restart_supervisor=False, requirements=False, no_backup=False, upgrade=False, force=False):
|
||||
@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):
|
||||
"Update bench"
|
||||
|
||||
if not (pull or patch or build or bench or requirements):
|
||||
@ -39,7 +40,8 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
|
||||
'requirements': requirements,
|
||||
'no-backup': no_backup,
|
||||
'restart-supervisor': restart_supervisor,
|
||||
'upgrade': upgrade
|
||||
'upgrade': upgrade,
|
||||
'reset':reset
|
||||
})
|
||||
|
||||
if conf.get('release_bench'):
|
||||
@ -57,10 +59,10 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
|
||||
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)
|
||||
_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, requirements=False, no_backup=False, upgrade=False, bench_path='.', force=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):
|
||||
conf = get_config(bench_path=bench_path)
|
||||
version_upgrade = is_version_upgrade(bench_path=bench_path)
|
||||
|
||||
@ -73,7 +75,7 @@ def _update(pull=False, patch=False, build=False, update_bench=False, auto=False
|
||||
before_update(bench_path=bench_path, requirements=requirements)
|
||||
|
||||
if pull:
|
||||
pull_all_apps(bench_path=bench_path)
|
||||
pull_all_apps(bench_path=bench_path, reset=reset)
|
||||
|
||||
if requirements:
|
||||
update_requirements(bench_path=bench_path)
|
||||
|
Loading…
Reference in New Issue
Block a user