summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmorph-cache-server5
-rw-r--r--morphcacheserver/repocache.py13
2 files changed, 14 insertions, 4 deletions
diff --git a/morph-cache-server b/morph-cache-server
index bb84915..3a121d4 100755
--- a/morph-cache-server
+++ b/morph-cache-server
@@ -65,11 +65,12 @@ class MorphCacheServer(cliapp.Application):
ref = self._unescape_parameter(request.query.ref)
try:
response.set_header('Cache-Control', 'no-cache')
- sha1 = repo_cache.resolve_ref(repo, ref)
+ sha1, tree = repo_cache.resolve_ref(repo, ref)
return {
'repo': '%s' % repo,
'ref': '%s' % ref,
- 'sha1': '%s' % sha1
+ 'sha1': '%s' % sha1,
+ 'tree': '%s' % tree
}
except Exception, e:
response.status = 404
diff --git a/morphcacheserver/repocache.py b/morphcacheserver/repocache.py
index c226ef4..b55692f 100644
--- a/morphcacheserver/repocache.py
+++ b/morphcacheserver/repocache.py
@@ -64,16 +64,25 @@ class RepoCache(object):
refs = [x.split() for x in refs]
else:
refs = [x.split() for x in refs if 'origin' in x]
- return refs[0][0]
+ return refs[0][0], self._tree_from_commit(repo_dir, refs[0][0])
+
except cliapp.AppException:
pass
+
if not self._is_valid_sha1(ref):
raise InvalidReferenceError(repo_url, ref)
try:
- return self._rev_list(ref).strip()
+ sha = self._rev_list(ref).strip()
+ return sha, self._tree_from_commit(repo_dir, sha)
except:
raise InvalidReferenceError(repo_url, ref)
+ def _tree_from_commit(self, repo_dir, commitsha):
+ commit_info = self.app.runcmd(['git', 'log', '-1',
+ '--format=format:%T', commitsha],
+ cwd=repo_dir)
+ return commit_info.strip()
+
def cat_file(self, repo_url, ref, filename):
quoted_url = self._quote_url(repo_url)
repo_dir = os.path.join(self.repo_cache_dir, quoted_url)