return env
-def list_refs(refname=None, repo_dir=None,
+def list_refs(refnames=None, repo_dir=None,
limit_to_heads=False, limit_to_tags=False):
- """Yield (refname, hash) tuples for all repository refs unless a ref
- name is specified. Given a ref name, only include tuples for that
- particular ref. The limits restrict the result items to
- refs/heads or refs/tags. If both limits are specified, items from
- both sources will be included.
+ """Yield (refname, hash) tuples for all repository refs unless
+ refnames are specified. In that case, only include tuples for
+ those refs. The limits restrict the result items to refs/heads or
+ refs/tags. If both limits are specified, items from both sources
+ will be included.
"""
argv = ['git', 'show-ref']
if limit_to_tags:
argv.append('--tags')
argv.append('--')
- if refname:
- argv += [refname]
+ if refnames:
+ argv += refnames
p = subprocess.Popen(argv,
preexec_fn = _gitenv(repo_dir),
stdout = subprocess.PIPE)
def read_ref(refname, repo_dir = None):
"""Get the commit id of the most recent commit made on a given ref."""
- refs = list_refs(refname, repo_dir=repo_dir, limit_to_heads=True)
+ refs = list_refs(refnames=[refname], repo_dir=repo_dir, limit_to_heads=True)
l = tuple(islice(refs, 2))
if l:
assert(len(l) == 1)