diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-03-23 17:20:51 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-03-23 17:20:51 +0000 |
commit | 80a9d3ee14688feada4bd799d02892ba66aa80fa (patch) | |
tree | 777b749729a5c6ca61768f642362dbb14782afb8 | |
parent | a117a2149cbfbe9df99b92df37e9a9c307256369 (diff) | |
download | morph-80a9d3ee14688feada4bd799d02892ba66aa80fa.tar.gz |
Make "morph edit" work when chunk already has the branch
-rwxr-xr-x | morph | 7 | ||||
-rwxr-xr-x | tests.branching/edit-checkouts-existing-chunk.script | 37 | ||||
-rw-r--r-- | tests.branching/edit-checkouts-existing-chunk.stdout | 4 |
3 files changed, 46 insertions, 2 deletions
@@ -487,8 +487,11 @@ class Morph(cliapp.Application): new_repo = os.path.join(mine_directory, system_branch, os.path.basename(repo)) self._clone_to_directory(new_repo, repo, ref) - self.runcmd(['git', 'checkout', '-b', system_branch, ref], - cwd=new_repo) + + system_branch = self._deduce_system_branch() + if system_branch != ref: + self.runcmd(['git', 'checkout', '-b', system_branch, ref], + cwd=new_repo) def cmd_merge(self, args): '''Merge specified repositories from another system branch.''' diff --git a/tests.branching/edit-checkouts-existing-chunk.script b/tests.branching/edit-checkouts-existing-chunk.script new file mode 100755 index 00000000..cc5977ca --- /dev/null +++ b/tests.branching/edit-checkouts-existing-chunk.script @@ -0,0 +1,37 @@ +#!/bin/sh +# Copyright (C) 2012 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +# Verify that "morph edit" clones a chunk repository into a system branch. + + +set -eu + +# Checkout the master system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" checkout master + +# Edit the hello chunk in master. +cd master/morphs +"$SRCDIR/scripts/test-morph" edit hello master + +echo "Current branches, morphs:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/master/morphs" branch + +echo "Current branches, hello:" +"$SRCDIR/scripts/run-git-in" "$DATADIR/mine/master/hello" branch + diff --git a/tests.branching/edit-checkouts-existing-chunk.stdout b/tests.branching/edit-checkouts-existing-chunk.stdout new file mode 100644 index 00000000..c5be6aed --- /dev/null +++ b/tests.branching/edit-checkouts-existing-chunk.stdout @@ -0,0 +1,4 @@ +Current branches, morphs: +* master +Current branches, hello: +* master |