mirror of
https://github.com/frappe/bench.git
synced 2025-02-10 22:58:30 +00:00
[fix] test_switch_to_branch - bring frappe back to develop
This commit is contained in:
parent
b0f571108d
commit
5a22215d62
13
bench/app.py
13
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:
|
||||||
@ -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)
|
||||||
|
@ -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)
|
||||||
|
|
||||||
@ -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