2
0
mirror of https://github.com/frappe/bench.git synced 2024-06-27 11:43:29 +00:00

fix: fixed frappe branch check

This commit is contained in:
Aradhya 2022-03-07 18:06:03 +05:30
parent c71fd096cc
commit 6c15327348
2 changed files with 11 additions and 10 deletions

View File

@ -49,12 +49,17 @@ def is_frappe_app(directory: str) -> bool:
return bool(is_frappe_app)
def is_valid_frappe_branch(frappe_path: str, frappe_branch: str):
def is_valid_frappe_branch(frappe_path, frappe_branch):
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
frappe_path = frappe_path.replace(".git", "")
try:
owner, repo = frappe_path.split("/")[3], frappe_path.split("/")[4]
except IndexError:
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]:
raise InvalidRemoteException
def log(message, level=0, no_log=False):

View File

@ -75,11 +75,7 @@ def init(
# remote apps
else:
frappe_path = frappe_path or "https://github.com/frappe/frappe.git"
frappe_branch = (
frappe_branch
if is_valid_frappe_branch(frappe_path, frappe_branch)
else None
)
is_valid_frappe_branch(frappe_path=frappe_path, frappe_branch=frappe_branch)
get_app(
frappe_path,
branch=frappe_branch,