mirror of
https://github.com/frappe/bench.git
synced 2025-01-08 16:14:12 +00:00
fix: fixed frappe branch check
This commit is contained in:
parent
c71fd096cc
commit
6c15327348
@ -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):
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user