summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2013-06-04 11:32:00 +0100
committerJonathan Maw <jonathan.maw@codethink.co.uk>2013-06-04 13:24:56 +0100
commit2b94817befc8538f85f454a8e112d7ae828ecf52 (patch)
treee8207db6d2b7977577914219954742003bd38fd7
parentfd8b593f02f72fd04bfafbbdbb8169c534f53e7d (diff)
downloadmorph-cache-server-2b94817befc8538f85f454a8e112d7ae828ecf52.tar.gz
Handle requesting a sha1 of a sha1
-rw-r--r--morphcacheserver/repocache.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/morphcacheserver/repocache.py b/morphcacheserver/repocache.py
index 668d8fb..cd2eab5 100644
--- a/morphcacheserver/repocache.py
+++ b/morphcacheserver/repocache.py
@@ -16,6 +16,7 @@
import cliapp
import os
+import re
import string
import urlparse
@@ -59,9 +60,13 @@ class RepoCache(object):
if not os.path.exists(repo_dir):
raise RepositoryNotFoundError(repo_url)
try:
- if not self.direct_mode and not ref.startswith('refs/origin/'):
- ref = 'refs/origin/' + ref
- sha1 = self._rev_parse(repo_dir, ref)
+ if re.match('^[0-9a-fA-F]{40}$', ref):
+ sha1 = ref
+ else:
+ if (not self.direct_mode and
+ not ref.startswith('refs/origin/')):
+ ref = 'refs/origin/' + ref
+ sha1 = self._rev_parse(repo_dir, ref)
return sha1, self._tree_from_commit(repo_dir, sha1)
except cliapp.AppException: