|
|
@@ -125,11 +125,22 @@ def install_db(root_login=None, root_password=None, db_name=None, source_sql=Non |
|
|
|
|
|
|
|
|
|
|
|
def find_org(org_repo: str) -> Tuple[str, str]: |
|
|
|
""" find the org a repo is in |
|
|
|
|
|
|
|
find_org() |
|
|
|
ref -> https://github.com/frappe/bench/blob/develop/bench/utils/__init__.py#L390 |
|
|
|
|
|
|
|
:param org_repo: |
|
|
|
:type org_repo: str |
|
|
|
|
|
|
|
:raises InvalidRemoteException: if the org is not found |
|
|
|
|
|
|
|
:return: organisation and repository |
|
|
|
:rtype: Tuple[str, str] |
|
|
|
""" |
|
|
|
from frappe.exceptions import InvalidRemoteException |
|
|
|
import requests |
|
|
|
|
|
|
|
org_repo = org_repo[0] |
|
|
|
|
|
|
|
for org in ["frappe", "erpnext"]: |
|
|
|
res = requests.head(f"https://api.github.com/repos/{org}/{org_repo}") |
|
|
|
if res.ok: |
|
|
@@ -139,6 +150,17 @@ def find_org(org_repo: str) -> Tuple[str, str]: |
|
|
|
|
|
|
|
|
|
|
|
def fetch_details_from_tag(_tag: str) -> Tuple[str, str, str]: |
|
|
|
""" parse org, repo, tag from string |
|
|
|
|
|
|
|
fetch_details_from_tag() |
|
|
|
ref -> https://github.com/frappe/bench/blob/develop/bench/utils/__init__.py#L403 |
|
|
|
|
|
|
|
:param _tag: input string |
|
|
|
:type _tag: str |
|
|
|
|
|
|
|
:return: organisation, repostitory, tag |
|
|
|
:rtype: Tuple[str, str, str] |
|
|
|
""" |
|
|
|
app_tag = _tag.split("@") |
|
|
|
org_repo = app_tag[0].split("/") |
|
|
|
|
|
|
@@ -150,12 +172,24 @@ def fetch_details_from_tag(_tag: str) -> Tuple[str, str, str]: |
|
|
|
try: |
|
|
|
org, repo = org_repo |
|
|
|
except Exception: |
|
|
|
org, repo = find_org(org_repo) |
|
|
|
org, repo = find_org(org_repo[0]) |
|
|
|
|
|
|
|
return org, repo, tag |
|
|
|
|
|
|
|
|
|
|
|
def parse_app_name(name: str): |
|
|
|
def parse_app_name(name: str) -> str: |
|
|
|
"""parse repo name from name |
|
|
|
|
|
|
|
__setup_details_from_git() |
|
|
|
ref -> https://github.com/frappe/bench/blob/develop/bench/app.py#L114 |
|
|
|
|
|
|
|
|
|
|
|
:param name: git tag |
|
|
|
:type name: str |
|
|
|
|
|
|
|
:return: repository name |
|
|
|
:rtype: str |
|
|
|
""" |
|
|
|
name = name.rstrip("/") |
|
|
|
if os.path.exists(name): |
|
|
|
repo = os.path.split(name)[-1] |
|
|
|