(ref_type, ref_name, repo)
| 28 | |
| 29 | |
| 30 | def _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 | |
| 54 | def get_branch_or_use_upstream(branch_name, arg, repo): |
no outgoing calls
no test coverage detected