mirror of
https://github.com/frappe/bench.git
synced 2025-02-10 14:48:35 +00:00
Merge pull request #517 from zerodhatech/bench-update-exclude-app
Bench update exclude apps from updating
This commit is contained in:
commit
0bb0c5b1bf
35
bench/app.py
35
bench/app.py
@ -63,6 +63,33 @@ def check_url(url, raise_err = True):
|
||||
|
||||
return True
|
||||
|
||||
def get_excluded_apps(bench_path='.'):
|
||||
try:
|
||||
with open(os.path.join(bench_path, 'sites', 'excluded_apps.txt')) as f:
|
||||
return f.read().strip().split('\n')
|
||||
except IOError:
|
||||
return []
|
||||
|
||||
def add_to_excluded_apps_txt(app, bench_path='.'):
|
||||
if app == 'frappe':
|
||||
raise ValueError('Frappe app cannot be excludeed from update')
|
||||
if app not in os.listdir('apps'):
|
||||
raise ValueError('The app {} does not exist'.format(app))
|
||||
apps = get_excluded_apps(bench_path=bench_path)
|
||||
if app not in apps:
|
||||
apps.append(app)
|
||||
return write_excluded_apps_txt(apps, bench_path=bench_path)
|
||||
|
||||
def write_excluded_apps_txt(apps, bench_path='.'):
|
||||
with open(os.path.join(bench_path, 'sites', 'excluded_apps.txt'), 'w') as f:
|
||||
return f.write('\n'.join(apps))
|
||||
|
||||
def remove_from_excluded_apps_txt(app, bench_path='.'):
|
||||
apps = get_excluded_apps(bench_path=bench_path)
|
||||
if app in apps:
|
||||
apps.remove(app)
|
||||
return write_excluded_apps_txt(apps, bench_path=bench_path)
|
||||
|
||||
def get_app(git_url, branch=None, bench_path='.', build_asset_files=True, verbose=False):
|
||||
# from bench.utils import check_url
|
||||
try:
|
||||
@ -169,6 +196,10 @@ def pull_all_apps(bench_path='.', reset=False):
|
||||
# chech for local changes
|
||||
if not reset:
|
||||
for app in get_apps(bench_path=bench_path):
|
||||
excluded_apps = get_excluded_apps()
|
||||
if app in excluded_apps:
|
||||
print("Skipping reset for app {}".format(app))
|
||||
continue
|
||||
app_dir = get_repo_dir(app, bench_path=bench_path)
|
||||
if os.path.exists(os.path.join(app_dir, '.git')):
|
||||
out = subprocess.check_output(["git", "status"], cwd=app_dir)
|
||||
@ -188,6 +219,10 @@ Here are your choices:
|
||||
sys.exit(1)
|
||||
|
||||
for app in get_apps(bench_path=bench_path):
|
||||
excluded_apps = get_excluded_apps()
|
||||
if app in excluded_apps:
|
||||
print("Skipping pull for app {}".format(app))
|
||||
continue
|
||||
app_dir = get_repo_dir(app, bench_path=bench_path)
|
||||
if os.path.exists(os.path.join(app_dir, '.git')):
|
||||
remote = get_remote(app)
|
||||
|
@ -181,3 +181,7 @@ def migrate_env(python, no_backup = False):
|
||||
raise
|
||||
|
||||
bench_command.add_command(migrate_env)
|
||||
|
||||
from bench.commands.make import exclude_app_for_update, include_app_for_update
|
||||
bench_command.add_command(exclude_app_for_update)
|
||||
bench_command.add_command(include_app_for_update)
|
||||
|
@ -52,3 +52,19 @@ def remove_app(app_name):
|
||||
"completely remove app from bench"
|
||||
from bench.app import remove_app
|
||||
remove_app(app_name)
|
||||
|
||||
|
||||
@click.command('exclude-app')
|
||||
@click.argument('app_name')
|
||||
def exclude_app_for_update(app_name):
|
||||
"Exclude app from updating"
|
||||
from bench.app import add_to_excluded_apps_txt
|
||||
add_to_excluded_apps_txt(app_name)
|
||||
|
||||
|
||||
@click.command('include-app')
|
||||
@click.argument('app_name')
|
||||
def include_app_for_update(app_name):
|
||||
"Include app from updating"
|
||||
from bench.app import remove_from_excluded_apps_txt
|
||||
remove_from_excluded_apps_txt(app_name)
|
||||
|
@ -6,17 +6,17 @@ from bench.utils import (update_bench, validate_upgrade, pre_upgrade, post_upgra
|
||||
update_requirements, update_node_packages, backup_all_sites, patch_sites, build_assets, restart_supervisor_processes)
|
||||
from bench import patches
|
||||
|
||||
#TODO: Not DRY
|
||||
|
||||
@click.command('update')
|
||||
@click.option('--pull', is_flag=True, help="Pull changes in all the apps in bench")
|
||||
@click.option('--patch',is_flag=True, help="Run migrations for all sites in the bench")
|
||||
@click.option('--build',is_flag=True, help="Build JS and CSS artifacts for the bench")
|
||||
@click.option('--bench',is_flag=True, help="Update bench")
|
||||
@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('--no-backup',is_flag=True)
|
||||
@click.option('--force',is_flag=True)
|
||||
@click.option('--patch', is_flag=True, help="Run migrations for all sites in the bench")
|
||||
@click.option('--build', is_flag=True, help="Build JS and CSS artifacts for the bench")
|
||||
@click.option('--bench', is_flag=True, help="Update bench")
|
||||
@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('--no-backup', 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")
|
||||
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"
|
||||
@ -39,7 +39,7 @@ def update(pull=False, patch=False, build=False, bench=False, auto=False, restar
|
||||
'requirements': requirements,
|
||||
'no-backup': no_backup,
|
||||
'restart-supervisor': restart_supervisor,
|
||||
'reset':reset
|
||||
'reset': reset
|
||||
})
|
||||
|
||||
if conf.get('release_bench'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user