From 4cadf2c719f5ecf2580c28b4b2e687d7d8a69e6b Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 10 May 2021 14:45:46 +0530 Subject: [PATCH 1/4] fix: Unshallow clone if update without --reset If an unshallow clone has to be updated, the only way to update it without a reset will require an unshallow. This is because there may be uncommitted or committed changes in any of the apps, although unfavoured should be handled safely. The only way to update such repos is via the user configured settings..or a ff only merge. --- bench/app.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bench/app.py b/bench/app.py index 872270ac..9970655e 100755 --- a/bench/app.py +++ b/bench/app.py @@ -272,6 +272,14 @@ Here are your choices: 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)) 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) logger.log('pulling {0}'.format(app)) if reset: From 096c2cfe6b7a25d9a20c9fc81105c56855d49965 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 10 May 2021 14:51:14 +0530 Subject: [PATCH 2/4] fix: Show step titles while running operations --- bench/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bench/utils.py b/bench/utils.py index 7bb312ba..1937672e 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -221,9 +221,11 @@ def update(pull=False, apps=None, patch=False, build=False, requirements=False, apps = [app.strip() for app in re.split(",| ", apps) if app] if pull: + print('Updating apps source...') pull_apps(apps=apps, bench_path=bench_path, reset=reset) if requirements: + print('Setting up requirements...') update_requirements(bench_path=bench_path) update_node_packages(bench_path=bench_path) @@ -232,6 +234,7 @@ def update(pull=False, apps=None, patch=False, build=False, requirements=False, patch_sites(bench_path=bench_path) if build: + print('Building assets...') build_assets(bench_path=bench_path) if version_upgrade[0] or (not version_upgrade[0] and force): From f46126ce2b0e9c8607df192a3337eefb03c63c5c Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 10 May 2021 14:51:52 +0530 Subject: [PATCH 3/4] chore: Remove deprecated option from config template --- bench/config/common_site_config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bench/config/common_site_config.py b/bench/config/common_site_config.py index 41d9cc9c..d7c492bf 100644 --- a/bench/config/common_site_config.py +++ b/bench/config/common_site_config.py @@ -8,7 +8,6 @@ import os default_config = { 'restart_supervisor_on_update': False, 'restart_systemd_on_update': False, - 'auto_update': False, 'serve_default_site': True, 'rebase_on_pull': False, 'frappe_user': getpass.getuser(), From 01abc561e07ab19d9c66b5f6d8b915497305d36f Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Mon, 10 May 2021 16:36:10 +0530 Subject: [PATCH 4/4] fix: Added warning for unshallow without --reset --- bench/utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bench/utils.py b/bench/utils.py index 1937672e..93d2bda5 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -112,6 +112,16 @@ def get_env_cmd(cmd, bench_path='.'): 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, 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, @@ -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:])) 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): validate_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path) conf.update({ "maintenance_mode": 1, "pause_scheduler": 1 })