2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-10 17:24:41 +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
parent 2363fe38d5
commit e3bd34c12c
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

@ -354,6 +354,10 @@ def get_app(
bench_setup = False bench_setup = False
apps_to_install = make_resolution_plan(app, bench) 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 is_bench_directory(bench_path):
if not init_bench: if not init_bench:
raise NotInBenchDirectoryError( raise NotInBenchDirectoryError(
@ -365,7 +369,11 @@ def get_app(
frappe_app = apps_to_install["frappe"] frappe_app = apps_to_install["frappe"]
bench_path = get_available_folder_name(f"{app.repo}-bench", bench_path) 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) os.chdir(bench_path)
bench_setup = True bench_setup = True
@ -378,9 +386,8 @@ def get_app(
}) })
if resolve: if resolve:
resolve_and_install( install_resolved_deps(
app=app, resolution,
bench=bench,
bench_path=bench_path, bench_path=bench_path,
skip_assets=skip_assets, skip_assets=skip_assets,
verbose=verbose, verbose=verbose,
@ -412,17 +419,14 @@ def get_app(
): ):
app.install(verbose=verbose, skip_assets=skip_assets) app.install(verbose=verbose, skip_assets=skip_assets)
def resolve_and_install( def install_resolved_deps(
app: App, resolution,
bench: "Bench",
bench_path=".", bench_path=".",
skip_assets=False, skip_assets=False,
verbose=False, verbose=False,
): ):
from bench.utils.app import check_existing_dir from bench.utils.app import check_existing_dir
resolution = make_resolution_plan(app, bench)
if "frappe" in resolution: if "frappe" in resolution:
# Terminal dependency # Terminal dependency
del resolution["frappe"] del resolution["frappe"]

View File

@ -11,6 +11,7 @@ from typing import List, Tuple
# imports - third party imports # imports - third party imports
import click import click
import requests
# imports - module imports # imports - module imports
from bench import PROJECT_NAME, VERSION from bench import PROJECT_NAME, VERSION
@ -48,6 +49,12 @@ def is_frappe_app(directory: str) -> bool:
return bool(is_frappe_app) 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): def log(message, level=0, no_log=False):
import bench import bench
import bench.cli import bench.cli

View File

@ -14,6 +14,7 @@ from bench.utils import (
run_frappe_cmd, run_frappe_cmd,
sudoers_file, sudoers_file,
which, which,
is_valid_frappe_branch,
) )
from bench.utils.bench import build_assets, clone_apps_from from bench.utils.bench import build_assets, clone_apps_from
from bench.utils.render import job from bench.utils.render import job
@ -74,7 +75,11 @@ def init(
# remote apps # remote apps
else: else:
frappe_path = frappe_path or "https://github.com/frappe/frappe.git" 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( get_app(
frappe_path, frappe_path,
branch=frappe_branch, branch=frappe_branch,