2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-18 11:05:12 +00:00

Merge pull request #1169 from gavindsouza/bench-update-no-reset

fix: Bench update no reset
This commit is contained in:
gavin 2021-05-10 18:51:39 +05:30 committed by GitHub
commit ac4c0efa3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 1 deletions

View File

@ -272,6 +272,14 @@ Here are your choices:
add_to_excluded_apps_txt(app, bench_path=bench_path) add_to_excluded_apps_txt(app, bench_path=bench_path)
print("Skipping pull for app {}, since remote doesn't exist, and adding it to excluded apps".format(app)) print("Skipping pull for app {}, since remote doesn't exist, and adding it to excluded apps".format(app))
continue continue
if not get_config(bench_path).get('shallow_clone') or not reset:
is_shallow = os.path.exists(os.path.join(app_dir, ".git", "shallow"))
if is_shallow:
s = " to safely pull remote changes." if not reset else ""
print(f"Unshallowing {app}{s}")
exec_cmd(f"git fetch {remote} --unshallow", cwd=app_dir)
branch = get_current_branch(app, bench_path=bench_path) branch = get_current_branch(app, bench_path=bench_path)
logger.log('pulling {0}'.format(app)) logger.log('pulling {0}'.format(app))
if reset: if reset:

View File

@ -8,7 +8,6 @@ import os
default_config = { default_config = {
'restart_supervisor_on_update': False, 'restart_supervisor_on_update': False,
'restart_systemd_on_update': False, 'restart_systemd_on_update': False,
'auto_update': False,
'serve_default_site': True, 'serve_default_site': True,
'rebase_on_pull': False, 'rebase_on_pull': False,
'frappe_user': getpass.getuser(), 'frappe_user': getpass.getuser(),

View File

@ -112,6 +112,16 @@ def get_env_cmd(cmd, bench_path='.'):
return os.path.abspath(os.path.join(bench_path, 'env', 'bin', cmd)) return os.path.abspath(os.path.join(bench_path, 'env', 'bin', cmd))
def pause_exec(seconds=10):
from time import sleep
for i in range(seconds, 0, -1):
print(f"Will continue execution in {i} seconds...", end="\r")
sleep(1)
print(" " * 40, end="\r")
def init(path, apps_path=None, no_procfile=False, no_backups=False, def init(path, apps_path=None, no_procfile=False, no_backups=False,
frappe_path=None, frappe_branch=None, verbose=False, clone_from=None, frappe_path=None, frappe_branch=None, verbose=False, clone_from=None,
skip_redis_config_generation=False, clone_without_update=False, ignore_exist=False, skip_assets=False, skip_redis_config_generation=False, clone_without_update=False, ignore_exist=False, skip_assets=False,
@ -208,6 +218,16 @@ def update(pull=False, apps=None, patch=False, build=False, requirements=False,
print("This update will cause a major version change in Frappe/ERPNext from {0} to {1}. \nThis would take significant time to migrate and might break custom apps.".format(*version_upgrade[1:])) print("This update will cause a major version change in Frappe/ERPNext from {0} to {1}. \nThis would take significant time to migrate and might break custom apps.".format(*version_upgrade[1:]))
click.confirm('Do you want to continue?', abort=True) click.confirm('Do you want to continue?', abort=True)
if not reset and conf.get('shallow_clone'):
log("""shallow_clone is set in your bench config.
However without passing the --reset flag, your repositories will be unshallowed.
To avoid this, cancel this operation and run `bench update --reset`.
Consider the consequences of `git reset --hard` on your apps before you run that.
To avoid seeing this warning, set shallow_clone to false in your common_site_config.json
""", level=3)
pause_exec(seconds=10)
if version_upgrade[0] or (not version_upgrade[0] and force): if 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)
conf.update({ "maintenance_mode": 1, "pause_scheduler": 1 }) conf.update({ "maintenance_mode": 1, "pause_scheduler": 1 })
@ -221,9 +241,11 @@ def update(pull=False, apps=None, patch=False, build=False, requirements=False,
apps = [app.strip() for app in re.split(",| ", apps) if app] apps = [app.strip() for app in re.split(",| ", apps) if app]
if pull: if pull:
print('Updating apps source...')
pull_apps(apps=apps, bench_path=bench_path, reset=reset) pull_apps(apps=apps, bench_path=bench_path, reset=reset)
if requirements: if requirements:
print('Setting up requirements...')
update_requirements(bench_path=bench_path) update_requirements(bench_path=bench_path)
update_node_packages(bench_path=bench_path) update_node_packages(bench_path=bench_path)
@ -232,6 +254,7 @@ def update(pull=False, apps=None, patch=False, build=False, requirements=False,
patch_sites(bench_path=bench_path) patch_sites(bench_path=bench_path)
if build: if build:
print('Building assets...')
build_assets(bench_path=bench_path) build_assets(bench_path=bench_path)
if version_upgrade[0] or (not version_upgrade[0] and force): if version_upgrade[0] or (not version_upgrade[0] and force):