MCPcopy Create free account
hub / github.com/gitless-vcs/gitless / _get_ref

Function _get_ref

gitless/cli/helpers.py:30–51  ·  view source on GitHub ↗
(ref_type, ref_name, repo)

Source from the content-addressed store, hash-verified

28
29
30def _get_ref(ref_type, ref_name, repo):
31 ref_type_cap = ref_type.capitalize()
32 r = getattr(repo, "lookup_" + ref_type)(ref_name)
33 if not r:
34 if '/' not in ref_name:
35 raise ValueError(
36 '{0} "{1}" doesn\'t exist'.format(ref_type_cap, ref_name))
37
38 # It might be a remote ref
39 remote, remote_ref = ref_name.split('/', 1)
40 try:
41 remote_repo = repo.remotes[remote]
42 except KeyError:
43 raise ValueError(
44 'Remote "{0}" doesn\'t exist, and there is no local '
45 '{1} "{2}"'.format(remote, ref_type_cap, ref_name))
46
47 r = getattr(remote_repo, "lookup_" + ref_type)(remote_ref)
48 if not r:
49 raise ValueError('{0} "{1}" doesn\'t exist in remote "{2}"'.format(
50 ref_type_cap, remote_ref, remote))
51 return r
52
53
54def get_branch_or_use_upstream(branch_name, arg, repo):

Callers 2

get_branchFunction · 0.85
get_tagFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected