2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-23 23:18:24 +00:00

refactor: Added messages on invalid remote exceptions

This commit is contained in:
Aradhya 2022-03-23 18:20:49 +05:30
parent ddd498ebd0
commit cd583f7822

View File

@ -66,7 +66,7 @@ def is_valid_frappe_branch(frappe_path:str, frappe_branch:str):
try: try:
owner, repo = frappe_path.split("/")[3], frappe_path.split("/")[4] owner, repo = frappe_path.split("/")[3], frappe_path.split("/")[4]
except IndexError: except IndexError:
raise InvalidRemoteException raise InvalidRemoteException("Invalid git url")
git_api_req = f"https://api.github.com/repos/{owner}/{repo}/branches" git_api_req = f"https://api.github.com/repos/{owner}/{repo}/branches"
res = requests.get(git_api_req).json() res = requests.get(git_api_req).json()
@ -74,10 +74,10 @@ def is_valid_frappe_branch(frappe_path:str, frappe_branch:str):
# slower alternative with no rate limit # slower alternative with no rate limit
github_req = f'https://github.com/{owner}/{repo}/tree/{frappe_branch}' github_req = f'https://github.com/{owner}/{repo}/tree/{frappe_branch}'
if requests.get(github_req).status_code != 200: if requests.get(github_req).status_code != 200:
raise InvalidRemoteException raise InvalidRemoteException("Invalid git url")
elif frappe_branch not in [x["name"] for x in res]: elif frappe_branch not in [x["name"] for x in res]:
raise InvalidRemoteException raise InvalidRemoteException("Frappe branch does not exist")
def log(message, level=0, no_log=False): def log(message, level=0, no_log=False):