Skip to content

Commit

Permalink
fix: fixed init in get-app and frappe versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Aradhya-Tripathi authored and saxenabhishek committed Feb 28, 2022
1 parent 210146d commit 88c2367
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.formatting.provider": "black"
}
22 changes: 13 additions & 9 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ def get_app(
bench_setup = False
apps_to_install = make_resolution_plan(app, bench)

if resolve:
resolution = make_resolution_plan(app, bench)
frappe_path, frappe_branch = resolution["frappe"].url, resolution["frappe"].tag

if not is_bench_directory(bench_path):
if not init_bench:
raise NotInBenchDirectoryError(
Expand All @@ -374,7 +378,11 @@ def get_app(

frappe_app = apps_to_install["frappe"]
bench_path = get_available_folder_name(f"{app.repo}-bench", bench_path)
init(path=bench_path, frappe_branch=frappe_app.tag)
init(
path=bench_path,
frappe_path=frappe_path if resolve else None,
frappe_branch=frappe_branch if resolve else branch,
)
os.chdir(bench_path)
bench_setup = True

Expand All @@ -387,9 +395,8 @@ def get_app(
})

if resolve:
resolve_and_install(
app=app,
bench=bench,
install_resolved_deps(
resolution,
bench_path=bench_path,
skip_assets=skip_assets,
verbose=verbose,
Expand Down Expand Up @@ -421,17 +428,14 @@ def get_app(
):
app.install(verbose=verbose, skip_assets=skip_assets)

def resolve_and_install(
app: App,
bench: "Bench",
def install_resolved_deps(
resolution,
bench_path=".",
skip_assets=False,
verbose=False,
):
from bench.utils.app import check_existing_dir


resolution = make_resolution_plan(app, bench)
if "frappe" in resolution:
# Terminal dependency
del resolution["frappe"]
Expand Down
7 changes: 7 additions & 0 deletions bench/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# imports - third party imports
import click
import requests

# imports - module imports
from bench import PROJECT_NAME, VERSION
Expand Down Expand Up @@ -48,6 +49,12 @@ def is_frappe_app(directory: str) -> bool:
return bool(is_frappe_app)


def is_valid_frappe_branch(frappe_path: str, frappe_branch: str):
url = frappe_path
url += "/tree/" + frappe_branch if frappe_branch else ""
return requests.get(url).status_code != 404


def log(message, level=0, no_log=False):
import bench
import bench.cli
Expand Down
7 changes: 6 additions & 1 deletion bench/utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
run_frappe_cmd,
sudoers_file,
which,
is_valid_frappe_branch,
)
from bench.utils.bench import build_assets, clone_apps_from
from bench.utils.render import job
Expand Down Expand Up @@ -74,7 +75,11 @@ def init(
# remote apps
else:
frappe_path = frappe_path or "https://github.com/frappe/frappe.git"

frappe_branch = (
frappe_branch
if is_valid_frappe_branch(frappe_path, frappe_branch)
else None
)
get_app(
frappe_path,
branch=frappe_branch,
Expand Down

0 comments on commit 88c2367

Please sign in to comment.