summaryrefslogtreecommitdiff
path: root/morphlib/cachedrepo_tests.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2012-12-13 12:36:07 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2012-12-13 15:37:53 +0000
commitde50cec19b4f7e4c5a6da5ecc5cddd7a52ac3725 (patch)
tree552fdae98cd0cc15d0b8a23ee225751b1d8ae374 /morphlib/cachedrepo_tests.py
parentd63c97a0bef1cd2f03ca266acda67cad065632df (diff)
downloadmorph-de50cec19b4f7e4c5a6da5ecc5cddd7a52ac3725.tar.gz
Always use `git rev-parse --verify` to resolve refs
Previously some code used `git show-ref`, which is wrong -- given two refs named 'alpha/master' and 'master', `git show-ref master` will return both, sorted alphabetically. This can lead to build failures, etc. due to refs resolving to the wrong SHAs. We should also use `git rev-parse --verify` to verify SHA1s, which we previously did with `git rev-list`. Finally, `git rev-parse --verify` is more than twice as fast as `git show-ref`.
Diffstat (limited to 'morphlib/cachedrepo_tests.py')
-rw-r--r--morphlib/cachedrepo_tests.py32
1 files changed, 9 insertions, 23 deletions
diff --git a/morphlib/cachedrepo_tests.py b/morphlib/cachedrepo_tests.py
index 81673880..0c1ec5de 100644
--- a/morphlib/cachedrepo_tests.py
+++ b/morphlib/cachedrepo_tests.py
@@ -31,19 +31,19 @@ class CachedRepoTests(unittest.TestCase):
"kind": "chunk"
}'''
- def show_ref(self, ref):
+ def rev_parse(self, ref):
output = {
- 'master':
- 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9'
- ' refs/heads/master',
- 'baserock/morph':
- '8b780e2e6f102fcf400ff973396566d36d730501'
- ' refs/heads/baserock/morph',
+ 'a4da32f5a81c8bc6d660404724cedc3bc0914a75':
+ 'a4da32f5a81c8bc6d660404724cedc3bc0914a75',
+ 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9':
+ 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9',
+ 'master': 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9',
+ 'baserock/morph': '8b780e2e6f102fcf400ff973396566d36d730501'
}
try:
return output[ref]
except:
- raise cliapp.AppException('git show-ref %s' % ref)
+ raise cliapp.AppException('git rev-parse --verify %s' % ref)
def show_tree_hash(self, absref):
output = {
@@ -60,19 +60,6 @@ class CachedRepoTests(unittest.TestCase):
raise cliapp.AppException('git log -1 --format=format:%%T %s' %
absref)
- def rev_list(self, ref):
- output = {
- 'master': 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9',
- 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9':
- 'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9',
- 'a4da32f5a81c8bc6d660404724cedc3bc0914a75':
- 'a4da32f5a81c8bc6d660404724cedc3bc0914a75',
- }
- try:
- return output[ref]
- except:
- raise cliapp.AppException('git rev-list %s' % ref)
-
def cat_file(self, ref, filename):
output = {
'e28a23812eadf2fce6583b8819b9c5dbd36b9fb9:foo.morph':
@@ -125,9 +112,8 @@ class CachedRepoTests(unittest.TestCase):
self.repo_path = '/tmp/foo'
self.repo = cachedrepo.CachedRepo(
object(), self.repo_name, self.repo_url, self.repo_path)
- self.repo._show_ref = self.show_ref
+ self.repo._rev_parse = self.rev_parse
self.repo._show_tree_hash = self.show_tree_hash
- self.repo._rev_list = self.rev_list
self.repo._cat_file = self.cat_file
self.repo._copy_repository = self.copy_repository
self.repo._checkout_ref = self.checkout_ref