2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-13 16:56:33 +00:00

fix: check for valid branch in resolve

This commit is contained in:
saxenabhishek 2022-03-10 12:59:14 +05:30
parent 17888a5ce5
commit 79765e6b25
2 changed files with 5 additions and 7 deletions

View File

@ -24,6 +24,7 @@ from bench.utils import (
get_available_folder_name,
is_bench_directory,
is_git_url,
is_valid_frappe_branch,
log,
run_frappe_cmd,
)
@ -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

View File

@ -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
@ -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)
@ -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