From 460227f17e01f9072b72062fae84f226133ec04c Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 30 Oct 2013 09:59:09 +0000 Subject: Don't remove an existing branch in 'morph branch' --- morphlib/plugins/branch_and_merge_new_plugin.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py index 9a0ee484..dba529d9 100644 --- a/morphlib/plugins/branch_and_merge_new_plugin.py +++ b/morphlib/plugins/branch_and_merge_new_plugin.py @@ -134,6 +134,9 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin): gd.update_submodules(self.app) gd.update_remotes() + except morphlib.sysbranchdir.SystemBranchDirectoryAlreadyExists as e: + logging.error('Caught exception: %s' % str(e)) + raise except BaseException as e: # Oops. Clean up. logging.error('Caught exception: %s' % str(e)) -- cgit v1.2.1 From 10e32aa257db6ac95959661bdc0e7759b822008a Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Thu, 31 Oct 2013 14:50:41 +0000 Subject: Some tests refactorized for better understanding. --- yarns/branches-workspaces.yarn | 22 +++++++++++----------- yarns/implementations.yarn | 6 +++++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/yarns/branches-workspaces.yarn b/yarns/branches-workspaces.yarn index cd3f7a0e..b90c054c 100644 --- a/yarns/branches-workspaces.yarn +++ b/yarns/branches-workspaces.yarn @@ -72,7 +72,7 @@ We can, instead, create a new system branch, off master. SCENARIO branch off master GIVEN a workspace AND a git server - WHEN creating system branch foo + WHEN user creates system branch foo THEN the system branch foo is checked out We can also branch off another system branch. However, we need to first @@ -82,7 +82,7 @@ to check for that locally. SCENARIO branch off non-master GIVEN a workspace AND a git server - WHEN creating system branch foo + WHEN user creates system branch foo AND pushing system branch foo to git server AND creating system branch bar, based on foo THEN the system branch bar is checked out @@ -147,7 +147,7 @@ current directory, things should fail. GIVEN a workspace AND a git server WHEN checking out the master system branch - AND creating system branch foo + AND user creates system branch foo AND attempting to report system branch in . THEN morph failed @@ -186,7 +186,7 @@ all the refs are unchanged. SCENARIO morph branch does not edit refs GIVEN a workspace AND a git server - WHEN creating system branch foo + WHEN user creates system branch foo THEN in branch foo, system test-system refs test-stratum in master AND in branch foo, stratum test-stratum refs test-chunk in master @@ -214,7 +214,7 @@ repositories referenced in the system branch. SCENARIO morph status reports changes correctly GIVEN a workspace AND a git server - WHEN creating system branch foo + WHEN user creates system branch foo THEN morph reports no outstanding changes in foo WHEN editing stratum test-stratum in system test-system in branch foo @@ -244,7 +244,7 @@ branch checkout. SCENARIO morph foreach runs command in each git repo GIVEN a workspace AND a git server - WHEN creating system branch foo + WHEN user creates system branch foo AND editing chunk test-chunk in test-stratum in test-system in branch foo AND running shell command in each repo in foo THEN morph ran command in test:morphs in foo @@ -261,7 +261,7 @@ unpetrify and verify that we have all the same refs as before. SCENARIO morph petrifies and unpetrifies GIVEN a workspace AND a git server - WHEN creating system branch foo + WHEN user creates system branch foo AND pushing system branch foo to git server AND remembering all refs in foo AND petrifying foo @@ -279,7 +279,7 @@ system branch itself, only the tag. SCENARIO morph tags a system branch GIVEN a workspace AND a git server - WHEN creating system branch foo + WHEN user creates system branch foo AND tagging system branch foo as test123 THEN morph tag test123 in foo is an annotated git tag AND morph tag test123 in foo refers to a petrified commit @@ -314,7 +314,7 @@ wouldn't need to worry about changing the system branch ref. GIVEN a workspace AND a git server AND null refs for local strata - WHEN creating system branch foo + WHEN user creates system branch foo THEN the system branch foo is checked out When we edit a morphology with null refs, they stay null. @@ -326,7 +326,7 @@ When we edit a morphology with null refs, they stay null. When creating the branch, the refs remain null. - WHEN creating system branch foo + WHEN user creates system branch foo THEN in branch foo, system test-system refs test-stratum in None After editing the stratum they remain null. @@ -347,7 +347,7 @@ Petrifying also leaves null refs unmolested GIVEN a workspace AND a git server AND null refs for local strata - WHEN creating system branch foo + WHEN user creates system branch foo AND pushing system branch foo to git server AND remembering all refs in foo AND petrifying foo diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn index 22120130..985ab2bc 100644 --- a/yarns/implementations.yarn +++ b/yarns/implementations.yarn @@ -183,10 +183,14 @@ We also need to verify that a system branch has been checked out. We can create a new branch, off master. - IMPLEMENTS WHEN creating system branch (\S+) + IMPLEMENTS WHEN user creates system branch (\S+) cd "$DATADIR/workspace" run_morph branch test:morphs "$MATCH_1" + IMPLEMENTS WHEN user attempts to create system branch (\S+) + cd "$DATADIR/workspace" + attempt_morph branch test:morphs "$MATCH_1" + We can create a new branch, off another system branch. IMPLEMENTS WHEN creating system branch (\S+), based on (\S+) -- cgit v1.2.1 From 8504f029bd2dffd1550b16c50d293aa58290d333 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Wed, 30 Oct 2013 10:45:39 +0000 Subject: Add regression test, morph branch doesn't remove existing branch dir --- yarns/regression.yarn | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/yarns/regression.yarn b/yarns/regression.yarn index d1cc8e79..7480655d 100644 --- a/yarns/regression.yarn +++ b/yarns/regression.yarn @@ -12,3 +12,23 @@ Testing if we can build after checking out from a tag. WHEN checking out the test-tag system tag THEN morph build the system simple-system of the tag test-tag of the repo test:morphs + +Running `morph branch` when the branch directory exists doesn't +remove the existing directory. + + SCENARIO re-running 'morph branch' fails, original branch untouched + GIVEN a workspace + AND a git server + WHEN user creates system branch foo + THEN the system branch foo is checked out + +The branch is checked out correctly, now it should fail if the user executes +`morph branch` with the same branch name. + + WHEN user attempts to create system branch foo + THEN morph failed + AND the branch error message includes the string "File exists" + +The branch still checked out. + + AND the system branch foo is checked out -- cgit v1.2.1