mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 00:37:51 +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:
|
with open(os.path.join(bench, 'sites', 'apps.txt'), 'w') as f:
|
||||||
return f.write('\n'.join(apps))
|
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))
|
logger.info('getting app {}'.format(app))
|
||||||
shallow_clone = '--depth 1' if check_git_for_shallow_clone() and get_config().get('shallow_clone') else ''
|
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)
|
install_app(app, bench=bench)
|
||||||
build_assets(bench=bench)
|
build_assets(bench=bench)
|
||||||
conf = get_config()
|
conf = get_config()
|
||||||
@ -59,7 +65,7 @@ def pull_all_apps(bench='.'):
|
|||||||
def install_apps_from_path(path, bench='.'):
|
def install_apps_from_path(path, bench='.'):
|
||||||
apps = get_apps_json(path)
|
apps = get_apps_json(path)
|
||||||
for app in apps:
|
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):
|
def get_apps_json(path):
|
||||||
if path.startswith('http'):
|
if path.startswith('http'):
|
||||||
|
10
bench/cli.py
10
bench/cli.py
@ -57,22 +57,24 @@ def bench(bench='.'):
|
|||||||
@click.argument('path')
|
@click.argument('path')
|
||||||
@click.option('--apps_path', default=None, help="path to json files with apps to install after init")
|
@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-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-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-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")
|
@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):
|
no_auto_update):
|
||||||
"Create a new bench"
|
"Create a new bench"
|
||||||
_init(path, apps_path=apps_path, no_procfile=no_procfile, no_backups=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)
|
no_auto_update=no_auto_update, frappe_path=frappe_path, frappe_branch=frappe_branch)
|
||||||
click.echo('Bench {} initialized'.format(path))
|
click.echo('Bench {} initialized'.format(path))
|
||||||
|
|
||||||
@click.command('get-app')
|
@click.command('get-app')
|
||||||
@click.argument('name')
|
@click.argument('name')
|
||||||
@click.argument('git-url')
|
@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"
|
"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.command('new-app')
|
||||||
@click.argument('app-name')
|
@click.argument('app-name')
|
||||||
|
@ -25,7 +25,7 @@ def get_frappe(bench='.'):
|
|||||||
return frappe
|
return frappe
|
||||||
|
|
||||||
def init(path, apps_path=None, no_procfile=False, no_backups=False,
|
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
|
from .app import get_app, install_apps_from_path
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
print 'Directory {} already exists!'.format(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)
|
prime_wheel_cache(bench=path)
|
||||||
if not frappe_path:
|
if not frappe_path:
|
||||||
frappe_path = 'https://github.com/frappe/frappe.git'
|
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:
|
if not no_procfile:
|
||||||
setup_procfile(bench=path)
|
setup_procfile(bench=path)
|
||||||
if not no_backups:
|
if not no_backups:
|
||||||
|
Loading…
Reference in New Issue
Block a user