Skip to content

Commit

Permalink
fix: Use App.app_name over repo attr
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed May 31, 2023
1 parent 3af6058 commit 4f42392
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
14 changes: 7 additions & 7 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def install(

verbose = bench.cli.verbose or verbose
app_name = get_app_name(self.bench.name, self.app_name)
if not resolved and self.repo != "frappe" and not ignore_resolution:
if not resolved and self.app_name != "frappe" and not ignore_resolution:
click.secho(
f"Ignoring dependencies of {self.name}. To install dependencies use --resolve-deps",
fg="yellow",
Expand Down Expand Up @@ -262,13 +262,13 @@ def _get_dependencies(self):
from bench.utils.app import get_required_deps, required_apps_from_hooks

if self.on_disk:
required_deps = os.path.join(self.mount_path, self.repo, "hooks.py")
required_deps = os.path.join(self.mount_path, self.app_name, "hooks.py")
try:
return required_apps_from_hooks(required_deps, local=True)
except IndexError:
return []
try:
required_deps = get_required_deps(self.org, self.repo, self.tag or self.branch)
required_deps = get_required_deps(self.org, self.app_name, self.tag or self.branch)
return required_apps_from_hooks(required_deps)
except Exception:
return []
Expand All @@ -290,16 +290,16 @@ def make_resolution_plan(app: App, bench: "Bench"):
decide what apps and versions to install and in what order
"""
resolution = OrderedDict()
resolution[app.repo] = app
resolution[app.app_name] = app

for app_name in app._get_dependencies():
dep_app = App(app_name, bench=bench)
is_valid_frappe_branch(dep_app.url, dep_app.branch)
dep_app.required_by = app.name
if dep_app.repo in resolution:
click.secho(f"{dep_app.repo} is already resolved skipping", fg="yellow")
if dep_app.app_name in resolution:
click.secho(f"{dep_app.app_name} is already resolved skipping", fg="yellow")
continue
resolution[dep_app.repo] = dep_app
resolution[dep_app.app_name] = dep_app
resolution.update(make_resolution_plan(dep_app, bench))
app.local_resolution = [repo_name for repo_name, _ in reversed(resolution.items())]
return resolution
Expand Down
4 changes: 2 additions & 2 deletions bench/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,13 @@ def insert(self, key, value):
def add(self, app: "App"):
app.get()
app.install()
super().append(app.repo)
super().append(app.app_name)
self.apps.sort()

def remove(self, app: "App", no_backup: bool = False):
app.uninstall()
app.remove(no_backup=no_backup)
super().remove(app.repo)
super().remove(app.app_name)

def append(self, app: "App"):
return self.add(app)
Expand Down
4 changes: 2 additions & 2 deletions bench/tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def test_init(self, bench_name="test-bench", **kwargs):
self.init_bench(bench_name, **kwargs)
app = App("file:///tmp/frappe")
self.assertTupleEqual(
(app.mount_path, app.url, app.repo, app.org),
("/tmp/frappe", "file:///tmp/frappe", "frappe", "frappe"),
(app.mount_path, app.url, app.repo, app.app_name, app.org),
("/tmp/frappe", "file:///tmp/frappe", "frappe", "frappe", "frappe"),
)
self.assert_folders(bench_name)
self.assert_virtual_env(bench_name)
Expand Down
4 changes: 3 additions & 1 deletion bench/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,6 @@ def test_app_states(self):

def test_ssh_ports(self):
app = App("git@github.com:22:frappe/frappe")
self.assertEqual((app.use_ssh, app.org, app.repo), (True, "frappe", "frappe"))
self.assertEqual(
(app.use_ssh, app.org, app.repo, app.app_name), (True, "frappe", "frappe", "frappe")
)

0 comments on commit 4f42392

Please sign in to comment.