Skip to content

Commit

Permalink
fix: check for valid branch in resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
saxenabhishek committed Mar 10, 2022
1 parent 17888a5 commit 79765e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 2 additions & 0 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
get_available_folder_name,
is_bench_directory,
is_git_url,
is_valid_frappe_branch,
log,
run_frappe_cmd,
)
Expand Down Expand Up @@ -244,6 +245,7 @@ def make_resolution_plan(app: App, bench: "Bench"):

for app_name in app._get_dependencies():
dep_app = App(app_name, bench=bench)
is_valid_frappe_branch(dep_app.url, dep_app.branch)
if dep_app.repo in resolution:
click.secho(f"{dep_app.repo} is already resolved skipping", fg="yellow")
continue
Expand Down
10 changes: 3 additions & 7 deletions bench/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def is_valid_frappe_branch(frappe_path, frappe_branch):
raise InvalidRemoteException
git_api = f"https://api.github.com/repos/{owner}/{repo}/branches"
res = requests.get(git_api).json()
if "message" in res or frappe_branch not in [x["name"] for x in res]:
if "message" in res or (frappe_branch and frappe_branch not in [x["name"] for x in res]):
raise InvalidRemoteException


Expand All @@ -76,9 +76,7 @@ def log(message, level=0, no_log=False):
color, prefix = levels.get(level, levels[0])

if bench.cli.from_command_line and bench.cli.dynamic_feed:
bench.LOG_BUFFER.append(
{"prefix": prefix, "message": message, "color": color}
)
bench.LOG_BUFFER.append({"prefix": prefix, "message": message, "color": color})

if no_log:
click.secho(message, fg=color)
Expand Down Expand Up @@ -196,9 +194,7 @@ def get_git_version() -> float:
def get_cmd_output(cmd, cwd=".", _raise=True):
output = ""
try:
output = subprocess.check_output(
cmd, cwd=cwd, shell=True, stderr=subprocess.PIPE, encoding="utf-8"
).strip()
output = subprocess.check_output(cmd, cwd=cwd, shell=True, stderr=subprocess.PIPE, encoding="utf-8").strip()
except subprocess.CalledProcessError as e:
if e.output:
output = e.output
Expand Down

0 comments on commit 79765e6

Please sign in to comment.