Skip to content

Commit

Permalink
fix: check current branch
Browse files Browse the repository at this point in the history
  • Loading branch information
saxenabhishek committed Mar 11, 2022
1 parent c71432d commit 2287f3f
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,19 +428,34 @@ def install_resolved_deps(
del resolution["frappe"]

for repo_name, app in reversed(resolution.items()):
existing_dir, _ = check_existing_dir(bench_path, repo_name)
existing_dir, path_to_app = check_existing_dir(bench_path, repo_name)
if existing_dir:
if bench.apps.states[repo_name]["resolution"]["branch"] != app.tag:
click.secho(
f"Incompatible version of {repo_name} is already installed",
fg="yellow",
is_compatible = False

installed_branch = bench.apps.states[repo_name]["resolution"]["branch"].strip()
if app.tag is None:
current_remote = (
subprocess.check_output(f"git config branch.{installed_branch}.remote", shell=True, cwd=path_to_app)
.decode("utf-8")
.rstrip()
)
app.install_resolved_apps(skip_assets=skip_assets, verbose=verbose)
else:
click.secho(
f"Compatible version of {repo_name} is already installed",
fg="yellow",

default_branch = (
subprocess.check_output(
f"git symbolic-ref refs/remotes/{current_remote}/HEAD", shell=True, cwd=path_to_app
)
.decode("utf-8")
.rsplit("/")[-1]
.strip()
)
is_compatible = default_branch == installed_branch
else:
is_compatible = bench.apps.states[repo_name]["resolution"]["branch"] == app.tag

click.secho(
f"{'C' if is_compatible else 'Inc'}ompatible version of {repo_name} is already installed",
fg="yellow",
)
continue
app.install_resolved_apps(skip_assets=skip_assets, verbose=verbose)

Expand Down

0 comments on commit 2287f3f

Please sign in to comment.