return ret
-
+def write_info_refs(refs, store):
+ """Generate info refs."""
+ for name, sha in sorted(refs.items()):
+ # get_refs() includes HEAD as a special case, but we don't want to
+ # advertise it
+ if name == 'HEAD':
+ continue
+ try:
+ o = store[sha]
+ except KeyError:
+ continue
+ peeled = store.peel_sha(sha)
+ yield '%s\t%s\n' % (o.id, name)
+ if o.id != peeled.id:
+ yield '%s\t%s^{}\n' % (peeled.id, name)
extract_capabilities,
extract_want_line_capabilities,
)
+from dulwich.refs import (
+ write_info_refs,
+ )
from dulwich.repo import (
Repo,
)
class BackendRepo(object):
"""Repository abstraction used by the Git server.
- Please note that the methods required here are a
- subset of those provided by dulwich.repo.Repo.
+ The methods required here are a subset of those provided by
+ dulwich.repo.Repo.
"""
object_store = None
def generate_info_refs(repo):
"""Generate an info refs file."""
refs = repo.get_refs()
- for name in sorted(refs.iterkeys()):
- # get_refs() includes HEAD as a special case, but we don't want to
- # advertise it
- if name == 'HEAD':
- continue
- sha = refs[name]
- o = repo.object_store[sha]
- if not o:
- continue
- yield '%s\t%s\n' % (sha, name)
- peeled_sha = repo.get_peeled(name)
- if peeled_sha != sha:
- yield '%s\t%s^{}\n' % (peeled_sha, name)
+ return write_info_refs(repo.get_refs(), repo.object_store)
def generate_objects_info_packs(repo):