diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-08-09 10:37:49 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2013-08-09 10:37:49 +0000 |
commit | dfb54752494a7260f9e707cb572df2f1acf306b6 (patch) | |
tree | 9dff8379a0be9777d2bdc472c0647ddcaa36ed1b | |
parent | 82cb8f46e5283f97e9a110adff8a49a60bcdb497 (diff) | |
parent | 7819677343bb40e899fa2cd252c203013911fede (diff) | |
download | definitions-dfb54752494a7260f9e707cb572df2f1acf306b6.tar.gz |
Merge commit '7819677343bb40e899fa2cd252c203013911fede'
-rw-r--r-- | morphlib/plugins/branch_and_merge_new_plugin.py | 25 | ||||
-rw-r--r-- | yarns/branches-workspaces.yarn | 18 | ||||
-rw-r--r-- | yarns/implementations.yarn | 14 |
3 files changed, 56 insertions, 1 deletions
diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py index 5a33d47b..e09417d2 100644 --- a/morphlib/plugins/branch_and_merge_new_plugin.py +++ b/morphlib/plugins/branch_and_merge_new_plugin.py @@ -15,6 +15,7 @@ import cliapp +import glob import logging import os import shutil @@ -22,6 +23,13 @@ import shutil import morphlib +class BranchRootHasNoSystemsError(cliapp.AppException): + def __init__(self, repo, ref): + cliapp.AppException.__init__( + self, 'System branch root repository %s ' + 'has no system morphologies at ref %s' % (repo, ref)) + + class SimpleBranchAndMergePlugin(cliapp.Plugin): '''Add subcommands for handling workspaces and system branches.''' @@ -131,6 +139,10 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): gd = sb.clone_cached_repo( cached_repo, system_branch, system_branch) + + if not self._checkout_has_systems(gd): + raise BranchRootHasNoSystemsError(root_url, system_branch) + gd.update_submodules(self.app) gd.update_remotes() except BaseException as e: @@ -202,6 +214,10 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): gd = sb.clone_cached_repo(cached_repo, system_branch, base_ref) gd.branch(system_branch, base_ref) gd.checkout(system_branch) + + if not self._checkout_has_systems(gd): + raise BranchRootHasNoSystemsError(root_url, base_ref) + gd.update_submodules(self.app) gd.update_remotes() except BaseException as e: @@ -267,3 +283,12 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): msg="WARNING: %(message)s", message=str(e), error=True) + @staticmethod + def _checkout_has_systems(gd): + for filename in glob.iglob(os.path.join(gd.dirname, '*.morph')): + with open(filename) as mf: + morphology = morphlib.morph2.Morphology(mf.read()) + if morphology['kind'] == 'system': + return True + return False + diff --git a/yarns/branches-workspaces.yarn b/yarns/branches-workspaces.yarn index bfcb9e66..3af362a1 100644 --- a/yarns/branches-workspaces.yarn +++ b/yarns/branches-workspaces.yarn @@ -58,6 +58,15 @@ Checking out a system branch should fail, if the branch doesn't exist. WHEN morph attempts to check out system branch foo THEN morph failed +Checking out a system branch should also fail if the repository does +not contain any system morphologies. + + SCENARIO checking out a system branch with no systems + GIVEN a workspace + AND a git server + WHEN morph attempts to check out a repository with no systems + THEN morph failed + We can, instead, create a new system branch, off master. SCENARIO branch off master @@ -78,6 +87,15 @@ to check for that locally. AND creating system branch bar, based on foo THEN the system branch bar is checked out +Similarly, attempting to branch a system branch should fail if the +repository does not contain any system morphologies. + + SCENARIO checking out a system branch with no systems + GIVEN a workspace + AND a git server + WHEN morph attempts to branch a repository with no systems + THEN morph failed + Query commands in workspaces ---------------------------- diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn index 6c0ef6e2..7f9281ac 100644 --- a/yarns/implementations.yarn +++ b/yarns/implementations.yarn @@ -124,7 +124,13 @@ Attempt to check out a system branch, and remember if it failed. IMPLEMENTS WHEN morph attempts to check out system branch (\S+) cd "$DATADIR/workspace" - attempt_morph checkout "$MATCH_1" + attempt_morph checkout test:morphs "$MATCH_1" + +Attempt to check out a system branch from a root that has no systems. + + IMPLEMENTS WHEN morph attempts to check out a repository with no systems + cd "$DATADIR/workspace" + attempt_morph checkout test:test-chunk master We also need to verify that a system branch has been checked out. @@ -145,6 +151,12 @@ We can create a new branch, off another system branch. cd "$DATADIR/workspace" run_morph branch test:morphs "$MATCH_1" "$MATCH_2" +Attempt to branch a system branch from a root that had no systems. + + IMPLEMENTS WHEN morph attempts to branch a repository with no systems + cd "$DATADIR/workspace" + attempt_morph branch test:test-chunk foo + Pushing all changes in a system branch checkout to the git server. IMPLEMENTS WHEN pushing system branch (\S+) to git server |