2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-24 04:59:01 +00:00

feat: added specific checks for git URLs

API Added: bench.utils.is_git_url
Reference: https://github.com/jonschlinkert/is-git-url
This commit is contained in:
Gavin D'souza 2020-05-14 17:45:28 +05:30
parent 74028074df
commit 30473d3535

View File

@ -71,6 +71,11 @@ def check_url(url, raise_err=True):
return True return True
def is_git_url(url):
# modified to allow without the tailing .git from https://github.com/jonschlinkert/is-git-url.git
pattern = r"(?:git|ssh|https?|git@[-\w.]+):(\/\/)?(.*?)(\.git)?(\/?|\#[-\d\w._]+?)$"
return bool(re.fullmatch(pattern, url))
def get_excluded_apps(bench_path='.'): def get_excluded_apps(bench_path='.'):
try: try:
with open(os.path.join(bench_path, 'sites', 'excluded_apps.txt')) as f: with open(os.path.join(bench_path, 'sites', 'excluded_apps.txt')) as f:
@ -100,9 +105,7 @@ def remove_from_excluded_apps_txt(app, bench_path='.'):
def get_app(git_url, branch=None, bench_path='.', skip_assets=False, verbose=False, postprocess=True, overwrite=False): def get_app(git_url, branch=None, bench_path='.', skip_assets=False, verbose=False, postprocess=True, overwrite=False):
if not os.path.exists(git_url): if not os.path.exists(git_url):
if git_url.startswith('git@'): if not is_git_url(git_url):
pass
elif not check_url(git_url, raise_err=False):
orgs = ['frappe', 'erpnext'] orgs = ['frappe', 'erpnext']
for org in orgs: for org in orgs:
url = 'https://api.github.com/repos/{org}/{app}'.format(org=org, app=git_url) url = 'https://api.github.com/repos/{org}/{app}'.format(org=org, app=git_url)