Skip to content

Commit

Permalink
fix: fixed app states and checking/updating frappe version on install
Browse files Browse the repository at this point in the history
fix: fixed valid branch check in init
  • Loading branch information
Aradhya-Tripathi committed Feb 7, 2022
1 parent e3bd34c commit 42f4d74
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
11 changes: 6 additions & 5 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
5 changes: 1 addition & 4 deletions bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -163,9 +162,7 @@ def initialize_states(self):
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:
Expand Down
8 changes: 5 additions & 3 deletions bench/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 42f4d74

Please sign in to comment.