mirror of
https://github.com/frappe/bench.git
synced 2025-01-10 00:37:51 +00:00
Merge branch 'develop' into staging
This commit is contained in:
commit
07c3c75cd3
19
bench/app.py
19
bench/app.py
@ -13,6 +13,8 @@ from datetime import date
|
|||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from markupsafe import soft_str
|
||||||
|
|
||||||
# imports - third party imports
|
# imports - third party imports
|
||||||
import click
|
import click
|
||||||
from git import Repo
|
from git import Repo
|
||||||
@ -141,7 +143,7 @@ class AppMeta:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def url(self):
|
def url(self):
|
||||||
if self.is_url:
|
if self.is_url or self.from_apps or self.on_disk:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
if self.use_ssh:
|
if self.use_ssh:
|
||||||
@ -158,8 +160,9 @@ class AppMeta:
|
|||||||
|
|
||||||
@functools.lru_cache(maxsize=None)
|
@functools.lru_cache(maxsize=None)
|
||||||
class App(AppMeta):
|
class App(AppMeta):
|
||||||
def __init__(self, name: str, branch: str = None, bench: "Bench" = None, *args, **kwargs):
|
def __init__(self, name: str, branch: str = None, bench: "Bench" = None, soft_link : bool = False, *args, **kwargs):
|
||||||
self.bench = bench
|
self.bench = bench
|
||||||
|
self.soft_link = soft_link
|
||||||
self.required_by = None
|
self.required_by = None
|
||||||
self.local_resolution = []
|
self.local_resolution = []
|
||||||
super().__init__(name, branch, *args, **kwargs)
|
super().__init__(name, branch, *args, **kwargs)
|
||||||
@ -169,12 +172,19 @@ class App(AppMeta):
|
|||||||
branch = f"--branch {self.tag}" if self.tag else ""
|
branch = f"--branch {self.tag}" if self.tag else ""
|
||||||
shallow = "--depth 1" if self.bench.shallow_clone else ""
|
shallow = "--depth 1" if self.bench.shallow_clone else ""
|
||||||
|
|
||||||
|
if not self.soft_link:
|
||||||
|
cmd = "git clone"
|
||||||
|
args = f"{self.url} {branch} {shallow} --origin upstream"
|
||||||
|
else:
|
||||||
|
cmd = "ln -s"
|
||||||
|
args = f"{self.name}"
|
||||||
|
|
||||||
fetch_txt = f"Getting {self.repo}"
|
fetch_txt = f"Getting {self.repo}"
|
||||||
click.secho(fetch_txt, fg="yellow")
|
click.secho(fetch_txt, fg="yellow")
|
||||||
logger.log(fetch_txt)
|
logger.log(fetch_txt)
|
||||||
|
|
||||||
self.bench.run(
|
self.bench.run(
|
||||||
f"git clone {self.url} {branch} {shallow} --origin upstream",
|
f"{cmd} {args}",
|
||||||
cwd=os.path.join(self.bench.name, "apps"),
|
cwd=os.path.join(self.bench.name, "apps"),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -338,6 +348,7 @@ def get_app(
|
|||||||
skip_assets=False,
|
skip_assets=False,
|
||||||
verbose=False,
|
verbose=False,
|
||||||
overwrite=False,
|
overwrite=False,
|
||||||
|
soft_link=False,
|
||||||
init_bench=False,
|
init_bench=False,
|
||||||
resolve_deps=False,
|
resolve_deps=False,
|
||||||
):
|
):
|
||||||
@ -354,7 +365,7 @@ def get_app(
|
|||||||
from bench.utils.app import check_existing_dir
|
from bench.utils.app import check_existing_dir
|
||||||
|
|
||||||
bench = Bench(bench_path)
|
bench = Bench(bench_path)
|
||||||
app = App(git_url, branch=branch, bench=bench)
|
app = App(git_url, branch=branch, bench=bench, soft_link=soft_link)
|
||||||
git_url = app.url
|
git_url = app.url
|
||||||
repo_name = app.repo
|
repo_name = app.repo
|
||||||
branch = app.tag
|
branch = app.tag
|
||||||
|
@ -130,6 +130,7 @@ def drop(path):
|
|||||||
@click.option("--branch", default=None, help="branch to checkout")
|
@click.option("--branch", default=None, help="branch to checkout")
|
||||||
@click.option("--overwrite", is_flag=True, default=False)
|
@click.option("--overwrite", is_flag=True, default=False)
|
||||||
@click.option("--skip-assets", is_flag=True, default=False, help="Do not build assets")
|
@click.option("--skip-assets", is_flag=True, default=False, help="Do not build assets")
|
||||||
|
@click.option("--soft-link", is_flag=True, default=False, help="Create a soft link to git repo instead of clone.")
|
||||||
@click.option(
|
@click.option(
|
||||||
"--init-bench", is_flag=True, default=False, help="Initialize Bench if not in one"
|
"--init-bench", is_flag=True, default=False, help="Initialize Bench if not in one"
|
||||||
)
|
)
|
||||||
@ -145,6 +146,7 @@ def get_app(
|
|||||||
name=None,
|
name=None,
|
||||||
overwrite=False,
|
overwrite=False,
|
||||||
skip_assets=False,
|
skip_assets=False,
|
||||||
|
soft_link=False,
|
||||||
init_bench=False,
|
init_bench=False,
|
||||||
resolve_deps=False,
|
resolve_deps=False,
|
||||||
):
|
):
|
||||||
@ -156,6 +158,7 @@ def get_app(
|
|||||||
branch=branch,
|
branch=branch,
|
||||||
skip_assets=skip_assets,
|
skip_assets=skip_assets,
|
||||||
overwrite=overwrite,
|
overwrite=overwrite,
|
||||||
|
soft_link=soft_link,
|
||||||
init_bench=init_bench,
|
init_bench=init_bench,
|
||||||
resolve_deps=resolve_deps,
|
resolve_deps=resolve_deps,
|
||||||
)
|
)
|
||||||
|
@ -39,8 +39,10 @@ class TestBenchInit(TestBenchBase):
|
|||||||
def test_init(self, bench_name="test-bench", **kwargs):
|
def test_init(self, bench_name="test-bench", **kwargs):
|
||||||
self.init_bench(bench_name, **kwargs)
|
self.init_bench(bench_name, **kwargs)
|
||||||
app = App("file:///tmp/frappe")
|
app = App("file:///tmp/frappe")
|
||||||
self.assertEqual(app.mount_path, "/tmp/frappe")
|
self.assertTupleEqual(
|
||||||
self.assertEqual(app.url, "https://github.com/frappe/frappe.git")
|
(app.mount_path, app.url, app.repo, app.org),
|
||||||
|
("/tmp/frappe", "file:///tmp/frappe", "frappe", "frappe"),
|
||||||
|
)
|
||||||
self.assert_folders(bench_name)
|
self.assert_folders(bench_name)
|
||||||
self.assert_virtual_env(bench_name)
|
self.assert_virtual_env(bench_name)
|
||||||
self.assert_config(bench_name)
|
self.assert_config(bench_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user