From 42f4d74beb5418de2cfb418ab103dc6e568871d1 Mon Sep 17 00:00:00 2001 From: Aradhya Date: Mon, 7 Feb 2022 10:13:15 +0530 Subject: [PATCH] fix: fixed app states and checking/updating frappe version on install fix: fixed valid branch check in init --- bench/app.py | 11 ++++++----- bench/bench.py | 5 +---- bench/utils/__init__.py | 8 +++++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bench/app.py b/bench/app.py index 70370c17..4299b032 100755 --- a/bench/app.py +++ b/bench/app.py @@ -352,11 +352,13 @@ def get_app( repo_name = app.repo branch = app.tag bench_setup = False - apps_to_install = make_resolution_plan(app, bench) + frappe_path, frappe_branch = None, None if resolve: resolution = make_resolution_plan(app, bench) - frappe_path, frappe_branch = resolution["frappe"].url, resolution["frappe"].tag + if "frappe" in resolution: + # Todo: Make frappe a terminal dependency for all frappe apps. + frappe_path, frappe_branch = resolution["frappe"].url, resolution["frappe"].tag if not is_bench_directory(bench_path): if not init_bench: @@ -367,12 +369,11 @@ def get_app( from bench.utils.system import init - frappe_app = apps_to_install["frappe"] bench_path = get_available_folder_name(f"{app.repo}-bench", bench_path) init( path=bench_path, - frappe_path=frappe_path if resolve else None, - frappe_branch=frappe_branch if resolve else branch, + frappe_path=frappe_path, + frappe_branch=frappe_branch if frappe_branch else branch, ) os.chdir(bench_path) bench_setup = True diff --git a/bench/bench.py b/bench/bench.py index 6a0081c3..804abf8f 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -152,7 +152,6 @@ class BenchApps(MutableSequence): def __init__(self, bench: Bench): self.bench = bench self.initialize_apps() - self.initialize_states() def initialize_states(self): try: @@ -163,9 +162,7 @@ class BenchApps(MutableSequence): self.states = json.loads(f.read() or "{}") def update_apps_states(self, app_name: str = None, resolution: str = None): - # Only tracking for app state for apps installed via `bench resolve-and-install`, - # Not all states can be maintained as some apps may not be install via bench resolve-and-install - # or may not be compatible with versioning + self.initialize_states() self.initialize_apps() apps_to_remove = [] for app in self.states: diff --git a/bench/utils/__init__.py b/bench/utils/__init__.py index 87998d69..b0402bee 100644 --- a/bench/utils/__init__.py +++ b/bench/utils/__init__.py @@ -50,9 +50,11 @@ def is_frappe_app(directory: str) -> bool: 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 + if "http" in frappe_path: + url = frappe_path + url += "/tree/" + frappe_branch if frappe_branch else "" + return requests.get(url).status_code != 404 + return True def log(message, level=0, no_log=False):