mirror of
https://github.com/frappe/bench.git
synced 2025-02-10 14:48:35 +00:00
[fix] test_switch_to_branch - bring frappe back to develop
This commit is contained in:
parent
b0f571108d
commit
5a22215d62
17
bench/app.py
17
bench/app.py
@ -13,18 +13,15 @@ import subprocess
|
|||||||
logging.basicConfig(level="DEBUG")
|
logging.basicConfig(level="DEBUG")
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class InvalidBranchException(Exception): pass
|
||||||
|
class InvalidRemoteException(Exception): pass
|
||||||
|
|
||||||
class MajorVersionUpgradeException(Exception):
|
class MajorVersionUpgradeException(Exception):
|
||||||
def __init__(self, message, upstream_version, local_version):
|
def __init__(self, message, upstream_version, local_version):
|
||||||
super(MajorVersionUpgradeException, self).__init__(message)
|
super(MajorVersionUpgradeException, self).__init__(message)
|
||||||
self.upstream_version = upstream_version
|
self.upstream_version = upstream_version
|
||||||
self.local_version = local_version
|
self.local_version = local_version
|
||||||
|
|
||||||
class InvalidBranchException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class InvalidRemoteException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_apps(bench='.'):
|
def get_apps(bench='.'):
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(bench, 'sites', 'apps.txt')) as f:
|
with open(os.path.join(bench, 'sites', 'apps.txt')) as f:
|
||||||
@ -67,7 +64,7 @@ def get_app(git_url, branch=None, bench='.', build_asset_files=True, verbose=Fal
|
|||||||
app_name = re.search(r'name\s*=\s*[\'"](.*)[\'"]', f.read().decode('utf-8')).group(1)
|
app_name = re.search(r'name\s*=\s*[\'"](.*)[\'"]', f.read().decode('utf-8')).group(1)
|
||||||
if repo_name != app_name:
|
if repo_name != app_name:
|
||||||
apps_path = os.path.join(os.path.abspath(bench), 'apps')
|
apps_path = os.path.join(os.path.abspath(bench), 'apps')
|
||||||
os.rename(os.path.join(apps_path, repo_name), os.path.join(apps_path, app_name))
|
os.rename(os.path.join(apps_path, repo_name), os.path.join(apps_path, app_name))
|
||||||
|
|
||||||
print 'installing', app_name
|
print 'installing', app_name
|
||||||
install_app(app=app_name, bench=bench, verbose=verbose)
|
install_app(app=app_name, bench=bench, verbose=verbose)
|
||||||
@ -115,12 +112,12 @@ def is_version_upgrade(app='frappe', bench='.', branch=None):
|
|||||||
try:
|
try:
|
||||||
fetch_upstream(app, bench=bench)
|
fetch_upstream(app, bench=bench)
|
||||||
except CommandFailedError, e:
|
except CommandFailedError, e:
|
||||||
raise InvalidRemoteException("No remote named Upstream for "+app)
|
raise InvalidRemoteException("No remote named upstream for {0}".format(app))
|
||||||
|
|
||||||
upstream_version = get_upstream_version(app=app, branch=branch, bench=bench)
|
upstream_version = get_upstream_version(app=app, branch=branch, bench=bench)
|
||||||
|
|
||||||
if not upstream_version:
|
if not upstream_version:
|
||||||
raise InvalidBranchException("Specified branch of app {} is not in upstream".format(app))
|
raise InvalidBranchException("Specified branch of app {0} is not in upstream".format(app))
|
||||||
|
|
||||||
local_version = get_major_version(get_current_version(app, bench=bench))
|
local_version = get_major_version(get_current_version(app, bench=bench))
|
||||||
upstream_version = get_major_version(upstream_version)
|
upstream_version = get_major_version(upstream_version)
|
||||||
@ -187,7 +184,7 @@ def switch_branch(branch, apps=None, bench='.', upgrade=False, check_upgrade=Tru
|
|||||||
if os.path.isdir(os.path.join(apps_dir, name))]
|
if os.path.isdir(os.path.join(apps_dir, name))]
|
||||||
if branch=="v4.x.x":
|
if branch=="v4.x.x":
|
||||||
apps.append('shopping_cart')
|
apps.append('shopping_cart')
|
||||||
|
|
||||||
for app in apps:
|
for app in apps:
|
||||||
app_dir = os.path.join(apps_dir, app)
|
app_dir = os.path.join(apps_dir, app)
|
||||||
if os.path.exists(app_dir):
|
if os.path.exists(app_dir):
|
||||||
|
@ -20,8 +20,6 @@ class TestBenchInit(unittest.TestCase):
|
|||||||
if os.path.exists(bench_path):
|
if os.path.exists(bench_path):
|
||||||
shutil.rmtree(bench_path, ignore_errors=True)
|
shutil.rmtree(bench_path, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_init(self, bench_name="test-bench", **kwargs):
|
def test_init(self, bench_name="test-bench", **kwargs):
|
||||||
self.init_bench(bench_name, **kwargs)
|
self.init_bench(bench_name, **kwargs)
|
||||||
|
|
||||||
@ -90,17 +88,17 @@ class TestBenchInit(unittest.TestCase):
|
|||||||
def test_get_app(self):
|
def test_get_app(self):
|
||||||
site_name = "test-site-2.dev"
|
site_name = "test-site-2.dev"
|
||||||
self.init_bench('test-bench')
|
self.init_bench('test-bench')
|
||||||
|
|
||||||
self.new_site(site_name)
|
self.new_site(site_name)
|
||||||
bench_path = os.path.join(self.benches_path, "test-bench")
|
bench_path = os.path.join(self.benches_path, "test-bench")
|
||||||
|
|
||||||
bench.app.get_app("https://github.com/frappe/frappe-client", bench=bench_path)
|
bench.app.get_app("https://github.com/frappe/frappe-client", bench=bench_path)
|
||||||
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", "frappeclient")))
|
self.assertTrue(os.path.exists(os.path.join(bench_path, "apps", "frappeclient")))
|
||||||
|
|
||||||
def test_install_app(self):
|
def test_install_app(self):
|
||||||
site_name = "test-site-3.dev"
|
site_name = "test-site-3.dev"
|
||||||
self.init_bench('test-bench')
|
self.init_bench('test-bench')
|
||||||
|
|
||||||
self.new_site(site_name)
|
self.new_site(site_name)
|
||||||
bench_path = os.path.join(self.benches_path, "test-bench")
|
bench_path = os.path.join(self.benches_path, "test-bench")
|
||||||
|
|
||||||
@ -120,7 +118,7 @@ class TestBenchInit(unittest.TestCase):
|
|||||||
|
|
||||||
def test_switch_to_branch(self):
|
def test_switch_to_branch(self):
|
||||||
self.init_bench('test-bench')
|
self.init_bench('test-bench')
|
||||||
|
|
||||||
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")
|
||||||
|
|
||||||
@ -128,6 +126,11 @@ class TestBenchInit(unittest.TestCase):
|
|||||||
out = subprocess.check_output(['git', 'status'], cwd=app_path)
|
out = subprocess.check_output(['git', 'status'], cwd=app_path)
|
||||||
self.assertTrue("master" in out)
|
self.assertTrue("master" in out)
|
||||||
|
|
||||||
|
# bring it back to develop!
|
||||||
|
bench.app.switch_branch(branch="develop", apps=["frappe"], bench=bench_path, check_upgrade=False)
|
||||||
|
out = subprocess.check_output(['git', 'status'], cwd=app_path)
|
||||||
|
self.assertTrue("develop" in out)
|
||||||
|
|
||||||
def init_bench(self, bench_name, **kwargs):
|
def init_bench(self, bench_name, **kwargs):
|
||||||
self.benches.append(bench_name)
|
self.benches.append(bench_name)
|
||||||
bench.utils.init(bench_name, **kwargs)
|
bench.utils.init(bench_name, **kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user