Skip to content

Commit

Permalink
feat: added specific checks for git URLs
Browse files Browse the repository at this point in the history
API Added: bench.utils.is_git_url
Reference: https://github.com/jonschlinkert/is-git-url
  • Loading branch information
gavindsouza committed May 14, 2020
1 parent 7402807 commit 30473d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bench/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def check_url(url, raise_err=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='.'):
try:
with open(os.path.join(bench_path, 'sites', 'excluded_apps.txt')) as f:
Expand Down Expand Up @@ -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):
if not os.path.exists(git_url):
if git_url.startswith('git@'):
pass
elif not check_url(git_url, raise_err=False):
if not is_git_url(git_url):
orgs = ['frappe', 'erpnext']
for org in orgs:
url = 'https://api.github.com/repos/{org}/{app}'.format(org=org, app=git_url)
Expand Down

0 comments on commit 30473d3

Please sign in to comment.