mirror of
https://github.com/frappe/bench.git
synced 2025-01-09 16:36:25 +00:00
add support for app branches
This commit is contained in:
parent
d46fa73824
commit
196278e7bf
12
bench/app.py
12
bench/app.py
@ -21,10 +21,16 @@ def add_to_appstxt(app, bench='.'):
|
||||
with open(os.path.join(bench, 'sites', 'apps.txt'), 'w') as f:
|
||||
return f.write('\n'.join(apps))
|
||||
|
||||
def get_app(app, git_url, bench='.'):
|
||||
def get_app(app, git_url, branch=None, bench='.'):
|
||||
logger.info('getting app {}'.format(app))
|
||||
shallow_clone = '--depth 1' if check_git_for_shallow_clone() and get_config().get('shallow_clone') else ''
|
||||
exec_cmd("git clone {git_url} {shallow_clone} --origin upstream {app}".format(git_url=git_url, app=app, shallow_clone=shallow_clone), cwd=os.path.join(bench, 'apps'))
|
||||
branch = '--branch {branch}'.format(branch=branch) if branch else ''
|
||||
exec_cmd("git clone {git_url} {branch} {shallow_clone} --origin upstream {app}".format(
|
||||
git_url=git_url,
|
||||
app=app,
|
||||
shallow_clone=shallow_clone,
|
||||
branch=branch),
|
||||
cwd=os.path.join(bench, 'apps'))
|
||||
install_app(app, bench=bench)
|
||||
build_assets(bench=bench)
|
||||
conf = get_config()
|
||||
@ -59,7 +65,7 @@ def pull_all_apps(bench='.'):
|
||||
def install_apps_from_path(path, bench='.'):
|
||||
apps = get_apps_json(path)
|
||||
for app in apps:
|
||||
get_app(app['name'], app['url'], bench=bench)
|
||||
get_app(app['name'], app['url'], branch=app.get('branch'), bench=bench)
|
||||
|
||||
def get_apps_json(path):
|
||||
if path.startswith('http'):
|
||||
|
10
bench/cli.py
10
bench/cli.py
@ -57,22 +57,24 @@ def bench(bench='.'):
|
||||
@click.argument('path')
|
||||
@click.option('--apps_path', default=None, help="path to json files with apps to install after init")
|
||||
@click.option('--frappe-path', default=None, help="path to frappe repo")
|
||||
@click.option('--frappe-branch', default=None, help="path to frappe repo")
|
||||
@click.option('--no-procfile', flag_value=True, type=bool, help="Pull changes in all the apps in bench")
|
||||
@click.option('--no-backups',flag_value=True, type=bool, help="Run migrations for all sites in the bench")
|
||||
@click.option('--no-auto-update',flag_value=True, type=bool, help="Build JS and CSS artifacts for the bench")
|
||||
def init(path, apps_path, frappe_path, no_procfile, no_backups,
|
||||
def init(path, apps_path, frappe_path, frappe_branch, no_procfile, no_backups,
|
||||
no_auto_update):
|
||||
"Create a new bench"
|
||||
_init(path, apps_path=apps_path, no_procfile=no_procfile, no_backups=no_backups,
|
||||
no_auto_update=no_auto_update, frappe_path=frappe_path)
|
||||
no_auto_update=no_auto_update, frappe_path=frappe_path, frappe_branch=frappe_branch)
|
||||
click.echo('Bench {} initialized'.format(path))
|
||||
|
||||
@click.command('get-app')
|
||||
@click.argument('name')
|
||||
@click.argument('git-url')
|
||||
def get_app(name, git_url):
|
||||
@click.option('--branch', default=None, help="branch to checkout")
|
||||
def get_app(name, git_url, branch):
|
||||
"clone an app from the internet and set it up in your bench"
|
||||
_get_app(name, git_url)
|
||||
_get_app(name, git_url, branch=branch)
|
||||
|
||||
@click.command('new-app')
|
||||
@click.argument('app-name')
|
||||
|
@ -25,7 +25,7 @@ def get_frappe(bench='.'):
|
||||
return frappe
|
||||
|
||||
def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
||||
no_auto_update=False, frappe_path=None, wheel_cache_dir=None):
|
||||
no_auto_update=False, frappe_path=None, frappe_branch=None, wheel_cache_dir=None):
|
||||
from .app import get_app, install_apps_from_path
|
||||
if os.path.exists(path):
|
||||
print 'Directory {} already exists!'.format(path)
|
||||
@ -44,7 +44,7 @@ def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
||||
prime_wheel_cache(bench=path)
|
||||
if not frappe_path:
|
||||
frappe_path = 'https://github.com/frappe/frappe.git'
|
||||
get_app('frappe', frappe_path, bench=path)
|
||||
get_app('frappe', frappe_path, branch=frappe_branch, bench=path)
|
||||
if not no_procfile:
|
||||
setup_procfile(bench=path)
|
||||
if not no_backups:
|
||||
|
Loading…
Reference in New Issue
Block a user