mirror of
https://github.com/frappe/bench.git
synced 2024-11-12 00:06:36 +00:00
Merge branch 'develop' into fix-setup-requirements
This commit is contained in:
commit
1935afa634
11
bench/app.py
11
bench/app.py
@ -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.match(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,7 +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 not check_url(git_url, raise_err=False):
|
if not is_git_url(git_url):
|
||||||
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)
|
||||||
@ -390,7 +395,7 @@ def switch_branch(branch, apps=None, bench_path='.', upgrade=False, check_upgrad
|
|||||||
bench.utils.log("Fetching upstream {0}for {1}".format("unshallow " if unshallow_flag else "", app))
|
bench.utils.log("Fetching upstream {0}for {1}".format("unshallow " if unshallow_flag else "", app))
|
||||||
|
|
||||||
bench.utils.exec_cmd("git remote set-branches upstream '*'", cwd=app_dir)
|
bench.utils.exec_cmd("git remote set-branches upstream '*'", cwd=app_dir)
|
||||||
bench.utils.exec_cmd("git fetch --all{0}".format(" --unshallow" if unshallow_flag else ""), cwd=app_dir)
|
bench.utils.exec_cmd("git fetch --all{0} --quiet".format(" --unshallow" if unshallow_flag else ""), cwd=app_dir)
|
||||||
|
|
||||||
if check_upgrade:
|
if check_upgrade:
|
||||||
version_upgrade = is_version_upgrade(app=app, bench_path=bench_path, branch=branch)
|
version_upgrade = is_version_upgrade(app=app, bench_path=bench_path, branch=branch)
|
||||||
@ -399,7 +404,7 @@ def switch_branch(branch, apps=None, bench_path='.', upgrade=False, check_upgrad
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print("Switching for "+app)
|
print("Switching for "+app)
|
||||||
bench.utils.exec_cmd("git checkout {0}".format(branch), cwd=app_dir)
|
bench.utils.exec_cmd("git checkout -f {0}".format(branch), cwd=app_dir)
|
||||||
|
|
||||||
if str(repo.active_branch) == branch:
|
if str(repo.active_branch) == branch:
|
||||||
switched_apps.append(app)
|
switched_apps.append(app)
|
||||||
|
@ -136,13 +136,15 @@ class TestBenchInit(TestBenchBase):
|
|||||||
bench_path = os.path.join(self.benches_path, "test-bench")
|
bench_path = os.path.join(self.benches_path, "test-bench")
|
||||||
app_path = os.path.join(bench_path, "apps", "frappe")
|
app_path = os.path.join(bench_path, "apps", "frappe")
|
||||||
|
|
||||||
bench.utils.exec_cmd("bench switch-to-branch version-12 frappe --upgrade", cwd=bench_path)
|
successful_switch = not bench.utils.exec_cmd("bench switch-to-branch version-12 frappe --upgrade", cwd=bench_path)
|
||||||
app_branch_after_switch = str(git.Repo(path=app_path).active_branch)
|
app_branch_after_switch = str(git.Repo(path=app_path).active_branch)
|
||||||
self.assertEqual("version-12", app_branch_after_switch)
|
if successful_switch:
|
||||||
|
self.assertEqual("version-12", app_branch_after_switch)
|
||||||
|
|
||||||
bench.utils.exec_cmd("bench switch-to-branch develop frappe --upgrade", cwd=bench_path)
|
successful_switch = not bench.utils.exec_cmd("bench switch-to-branch develop frappe --upgrade", cwd=bench_path)
|
||||||
app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch)
|
app_branch_after_second_switch = str(git.Repo(path=app_path).active_branch)
|
||||||
self.assertEqual("develop", app_branch_after_second_switch)
|
if successful_switch:
|
||||||
|
self.assertEqual("develop", app_branch_after_second_switch)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user