diff --git a/bench/commands/make.py b/bench/commands/make.py index 10c3b67a..744f961c 100755 --- a/bench/commands/make.py +++ b/bench/commands/make.py @@ -8,13 +8,14 @@ import click @click.option('--frappe-path', default=None, help="path to frappe repo") @click.option('--frappe-branch', default=None, help="path to frappe repo") @click.option('--clone-from', default=None, help="copy repos from path") +@click.option('--clone-without-update', is_flag=True, help="copy repos from path without update") @click.option('--no-procfile', is_flag=True, help="Pull changes in all the apps in bench") @click.option('--no-backups',is_flag=True, help="Run migrations for all sites in the bench") @click.option('--no-auto-update',is_flag=True, help="Build JS and CSS artifacts for the bench") @click.option('--skip-redis-config-generation', is_flag=True, help="Skip redis config generation if already specifying the common-site-config file") @click.option('--verbose',is_flag=True, help="Verbose output during install") def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups, - no_auto_update, clone_from, verbose, skip_redis_config_generation, + no_auto_update, clone_from, verbose, skip_redis_config_generation, clone_without_update, ignore_exist = False, python = 'python'): # Let's change we're ready. - ''' @@ -24,6 +25,7 @@ def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups, init(path, apps_path=apps_path, no_procfile=no_procfile, no_backups=no_backups, no_auto_update=no_auto_update, frappe_path=frappe_path, frappe_branch=frappe_branch, verbose=verbose, clone_from=clone_from, skip_redis_config_generation=skip_redis_config_generation, + clone_without_update=clone_without_update, ignore_exist = ignore_exist, python = python) click.echo('Bench {} initialized'.format(path)) diff --git a/bench/utils.py b/bench/utils.py index a9f96229..5ca1395e 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -36,6 +36,7 @@ def get_env_cmd(cmd, bench_path='.'): def init(path, apps_path=None, no_procfile=False, no_backups=False, no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None, verbose=False, clone_from=None, skip_redis_config_generation=False, + clone_without_update=False, ignore_exist = False, python = 'python'): # Let's change when we're ready. - from .app import get_app, install_apps_from_path @@ -56,7 +57,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, try: os.makedirs(os.path.join(path, dirname)) except OSError as e: - if e.errno != os.errno.EEXIST: + if e.errno == os.errno.EEXIST: pass setup_logging() @@ -66,7 +67,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, make_config(path) if clone_from: - clone_apps_from(bench_path=path, clone_from=clone_from) + clone_apps_from(bench_path=path, clone_from=clone_from, update_app=not clone_without_update) else: if not frappe_path: frappe_path = 'https://github.com/frappe/frappe.git' @@ -94,7 +95,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False, if not no_auto_update: setup_auto_update(bench_path=path) -def clone_apps_from(bench_path, clone_from): +def clone_apps_from(bench_path, clone_from, update_app=True): from .app import install_app print('Copying apps from {0}...'.format(clone_from)) subprocess.check_output(['cp', '-R', os.path.join(clone_from, 'apps'), bench_path]) @@ -107,22 +108,22 @@ def clone_apps_from(bench_path, clone_from): def setup_app(app): # run git reset --hard in each branch, pull latest updates and install_app app_path = os.path.join(bench_path, 'apps', app) - if os.path.exists(os.path.join(app_path, '.git')): - print('Cleaning up {0}'.format(app)) - # remove .egg-ino - subprocess.check_output(['rm', '-rf', app + '.egg-info'], cwd=app_path) + # remove .egg-ino + subprocess.check_output(['rm', '-rf', app + '.egg-info'], cwd=app_path) + if update_app and os.path.exists(os.path.join(app_path, '.git')): remotes = subprocess.check_output(['git', 'remote'], cwd=app_path).strip().split() if 'upstream' in remotes: remote = 'upstream' else: remote = remotes[0] + print('Cleaning up {0}'.format(app)) branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=app_path).strip() subprocess.check_output(['git', 'reset', '--hard'], cwd=app_path) subprocess.check_output(['git', 'pull', '--rebase', remote, branch], cwd=app_path) - install_app(app, bench_path) + install_app(app, bench_path) with open(os.path.join(clone_from, 'sites', 'apps.txt'), 'r') as f: apps = f.read().splitlines()