summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmorph2
-rw-r--r--morphlib/cachedrepo.py9
-rw-r--r--morphlib/cachedrepo_tests.py8
-rw-r--r--tests.branching/checkout-existing-branch.stdout2
-rw-r--r--tests.branching/edit-checkouts-existing-chunk.stdout3
5 files changed, 13 insertions, 11 deletions
diff --git a/morph b/morph
index 60c5ad2f..68a6e9d9 100755
--- a/morph
+++ b/morph
@@ -592,7 +592,7 @@ class Morph(cliapp.Application):
repo.update()
# Clone it from cache to target directory.
- morphlib.git.clone(dirname, repo.path, self.msg)
+ repo.checkout(ref, os.path.abspath(dirname))
# Set the origin to point at the original repository.
morphlib.git.set_remote(dirname, 'origin', repo.url)
diff --git a/morphlib/cachedrepo.py b/morphlib/cachedrepo.py
index 0f348196..7d2bae4b 100644
--- a/morphlib/cachedrepo.py
+++ b/morphlib/cachedrepo.py
@@ -149,15 +149,10 @@ class CachedRepo(object):
raise CheckoutDirectoryExistsError(self, target_dir)
os.mkdir(target_dir)
-
- try:
- sha1 = self._rev_list(ref).strip()
- except morphlib.execute.CommandFailure:
- raise InvalidReferenceError(self, ref)
try:
self._copy_repository(self.path, target_dir)
- self._checkout_ref(sha1, target_dir)
+ self._checkout_ref(ref, target_dir)
except morphlib.execute.CommandFailure:
raise CheckoutError(self, ref, target_dir)
@@ -189,7 +184,7 @@ class CachedRepo(object):
target_dir])
def _checkout_ref(self, ref, target_dir): # pragma: no cover
- self.ex.runv(['git', 'checkout', ref], pwd=target_dir)
+ self.ex.runv(['git', 'checkout', ref], cwd=target_dir)
def _update(self): # pragma: no cover
self.ex.runv(['git', 'remote', 'update', 'origin'])
diff --git a/morphlib/cachedrepo_tests.py b/morphlib/cachedrepo_tests.py
index 127a866b..f3d4d1fc 100644
--- a/morphlib/cachedrepo_tests.py
+++ b/morphlib/cachedrepo_tests.py
@@ -65,7 +65,11 @@ class CachedRepoTests(unittest.TestCase):
pass
def checkout_ref(self, ref, target_dir):
- if ref == 'a4da32f5a81c8bc6d660404724cedc3bc0914a75':
+ bad_refs = [
+ 'a4da32f5a81c8bc6d660404724cedc3bc0914a75',
+ '079bbfd447c8534e464ce5d40b80114c2022ebf4',
+ ]
+ if ref in bad_refs:
# simulate a git failure or something similar to
# trigger a CheckoutError
raise morphlib.execute.CommandFailure('git checkout %s' % ref, '')
@@ -153,7 +157,7 @@ class CachedRepoTests(unittest.TestCase):
self.tempdir.dirname)
def test_fail_checkout_from_invalid_ref(self):
- self.assertRaises(cachedrepo.InvalidReferenceError, self.repo.checkout,
+ self.assertRaises(cachedrepo.CheckoutError, self.repo.checkout,
'079bbfd447c8534e464ce5d40b80114c2022ebf4',
self.tempdir.join('checkout-from-invalid-ref'))
diff --git a/tests.branching/checkout-existing-branch.stdout b/tests.branching/checkout-existing-branch.stdout
index 4b29db80..998b8acc 100644
--- a/tests.branching/checkout-existing-branch.stdout
+++ b/tests.branching/checkout-existing-branch.stdout
@@ -8,5 +8,7 @@ d ./.morph/cache/gits/file_morphs/.git
d ./master
d ./master/morphs
d ./master/morphs/.git
+f ./master/morphs/hello-stratum.chunk
+f ./master/morphs/hello-system.chunk
Current branches:
* master
diff --git a/tests.branching/edit-checkouts-existing-chunk.stdout b/tests.branching/edit-checkouts-existing-chunk.stdout
index a06832c2..929db3e4 100644
--- a/tests.branching/edit-checkouts-existing-chunk.stdout
+++ b/tests.branching/edit-checkouts-existing-chunk.stdout
@@ -1,5 +1,6 @@
Current branches, morphs:
-* master
+* alfred
+ master
Current branches, hello:
* alfred
master