2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-28 06:49:06 +00:00

fix: fixed init in get-app and frappe versions

This commit is contained in:
Aradhya 2022-02-04 20:50:35 +05:30 committed by saxenabhishek
parent 210146d222
commit 88c23673d6
4 changed files with 29 additions and 10 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.formatting.provider": "black"
}

View File

@ -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(
@ -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
@ -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,
@ -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"]

View File

@ -11,6 +11,7 @@ from typing import List, Tuple
# imports - third party imports
import click
import requests
# imports - module imports
from bench import PROJECT_NAME, VERSION
@ -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

View File

@ -14,6 +14,7 @@ from bench.utils import (
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
@ -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,