Skip to content

Commit

Permalink
fix: fixed frappe branch check
Browse files Browse the repository at this point in the history
  • Loading branch information
Aradhya-Tripathi committed Mar 7, 2022
1 parent c71fd09 commit 6c15327
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 10 additions & 5 deletions bench/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 1 addition & 5 deletions bench/utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6c15327

Please sign in to comment.