summaryrefslogtreecommitdiff
path: root/morphlib/cachedrepo.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-10-23 15:54:02 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-10-23 15:54:02 +0000
commit469459ac1a4cd3bd7b5161fe8d71567190257b56 (patch)
tree14f5ad7e2b681b56efcddd8f9ec74492b53a5dd0 /morphlib/cachedrepo.py
parent7a11ffef90359abf7907fbe6d6afd153fb4ed745 (diff)
downloadmorph-469459ac1a4cd3bd7b5161fe8d71567190257b56.tar.gz
Fix CachedRepo.resolve_ref unit test for missing SHA1
CachedRepo.resolve_ref does, effectively, this: absref = git rev-parse --verify $ref git log -1 --format=format:%T $absref Roughly, "git rev-parse" takes any ref and returns the corresponding SHA1. If the ref looks like a SHA1 (40 hex digits), it is returned as-is, and despite --verify is not checked for existence. "git log" then takes the SHA1 and returns the **tree** SHA1, as opposed to the commit one, and if the commit doesn't exist, barfs. The unit test for resolve_ref with an invalid SHA1 currently succeeds for the wrong reason. The mocked _rev_parse fails for an unknown SHA1 (raising cliapp.AppException), which causes resolve_ref to raise InvalidReferenceError, which the unit test expects. However, the real implementation of _rev_parse wouldn't fail in that way, and so the unit test doesn't test the thing it's meant to test: that resolve_ref actually works the expected way for an unknown SHA1. What actually happens is that resolve_ref calls _show_tree_hash, which raises cliapp.AppException for an unknown SHA1, resulting in horror and despair, instead of resolve_ref raising InvalidReferenceError. This commit fixes the unit test so that it causes the right code path in resolve_ref to be executed. This makes the unit test suite to fail.
Diffstat (limited to 'morphlib/cachedrepo.py')
0 files changed, 0 insertions, 0 deletions