Returns a :class:`Path <pathlib.Path>` to where this specific branch is stored on disk.

        :param repo: Repo URL
        :param branch: branch
        :return: Path to where the specific branch from this repo is being cloned.
343201
def get_path_to_repo_and_branch(self, repo: str, branch: str) -> Path:
        
        return self.get_path_to_repo(repo).resolve() / branch
896321
def get_repo_relpath(repo, relpath):
    
    from os import path
    if relpath[0:2] == "./":
        return path.join(repo, relpath[2::])
    else:
        from os import chdir, getcwd
        cd = getcwd()
        chdir(path.expanduser(repo))
        result = path.abspath(relpath)
        chdir(cd)
        return result
368223
def get_git_remote_url(path='.', remote='origin'):
    
    return dulwich.repo.Repo.discover(path).get_config()\
        .get((b'remote', remote.encode('utf-8')), b'url').decode('utf-8')
1087815
def git_clone(target_dir, repo_location, branch_or_tag=None, verbose=True):
    
    target_dir = pipes.quote(target_dir)
    command = ['git', 'clone']
    if verbose:
        command.append('--verbose')
    if os.path.isdir(repo_location):
        command.append('--no-hardlinks')
    command.extend([pipes.quote(repo_location), target_dir])
    if branch_or_tag:
        command.extend(['--branch', branch_or_tag])
    return execute_git_command(command)
1351627
def _git_dir(repo, path):
    
    name = "%s" % (path,)
    if name in ['HEAD', 'ORIG_HEAD', 'FETCH_HEAD', 'index', 'logs']:
        return repo.git_dir
    return repo.common_dir
220118
def _get_save_path(self, bury=False):
        """"""
        filename = self.get_filename(self[self._KEYS.NAME])

        # Put objects that shouldn't belong in this catalog in the boneyard
        if bury:
            outdir = self.catalog.get_repo_boneyard()

        # Get normal repository save directory
        else:
            repo_folders = self.catalog.PATHS.get_repo_output_folders()
            # If no repo folders exist, raise an error -- cannot save
            if not len(repo_folders):
                err_str = (
                    "No output data repositories found. Cannot save.\n"
                    "Make sure that repo names are correctly configured "
                    "in the `input/repos.json` file, and either manually or "
                    "automatically (using `astrocats CATALOG git-clone`) "
                    "clone the appropriate data repositories.")
                self.catalog.log.error(err_str)
                raise RuntimeError(err_str)

            outdir = repo_folders[0]

        return outdir, filename
987683
def _get_branch(repo, name):
    '''
    
    '''
    try:
        return [x for x in _all_branches(repo) if x[0] == name][0]
    except IndexError:
        return False
944048
def get_branch(self, branch):
        
        assert isinstance(branch, (str, unicode)), branch
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/branches/" + branch
        )
        return github.Branch.Branch(self._requester, headers, data, completed=True)
1041676
def branches(self):
		
		req_message = 'https://api.bitbucket.org/1.0/repositories/' + self.reponame + '/branches'
		response_data = self._bitbucketAPIRequest(req_message)
		return response_data.keys()
93037
def _to_relative_path(self, path):
        """"""
        if not osp.isabs(path):
            return path
        if self.repo.bare:
            raise InvalidGitRepositoryError("require non-bare repository")
        if not path.startswith(self.repo.working_tree_dir):
            raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
        return os.path.relpath(path, self.repo.working_tree_dir)
153211
def get_branch_details(repo: GithubRepository, branch: str) -> Any:
    
    url = ("https://api.github.com/repos/{}/{}/branches/{}"
           "?access_token={}".format(repo.organization,
                                     repo.name,
                                     branch,
                                     repo.access_token))
    response = requests.get(url)

    if response.status_code != 200:
        raise RuntimeError(
            'Failed to get branch details. Code: {}. Content: {}.'.format(
                response.status_code, response.content))

    return json.JSONDecoder().decode(response.content.decode())
1219821
def bitbucket(branch: str):
    
    assert os.environ.get('BITBUCKET_BRANCH') == branch
    assert not os.environ.get('BITBUCKET_PR_ID')
515660
def _get_branch(self, remotes=False):
        '''
        
        '''

        return self.m(
            'getting git branch information',
            cmdd=dict(
                cmd='git branch %s' % ('-r' if remotes else ''),
                cwd=self.local
            ),
            verbose=False
        )
909893
def _git_repo_path(self):
        
        logger.debug('Checking for git directory in: %s', self._package_top_dir)
        for p in self._package_top_dir:
            gitdir = os.path.join(p, '.git')
            if os.path.exists(gitdir):
                logger.debug('_is_git_clone() true based on %s' % gitdir)
                return gitdir
        logger.debug('_is_git_clone() false')
        return None
971161
def tree_lookup(self, target_path, commit):
        
        segments = target_path.split("/")
        tree_or_blob = commit.tree
        path = ''
        while segments:
            dirent = segments.pop(0)
            if isinstance(tree_or_blob, pygit2.Tree):
                if dirent in tree_or_blob:
                    tree_or_blob = self.repo[tree_or_blob[dirent].oid]
                    # self.logger.debug("  %s in %s" % (dirent, path))
                    if path:
                        path += '/'
                    path += dirent
                else:
                    # This is probably because we were called on a
                    # commit whose parent added a new directory.
                    self.logger.debug("        %s not in %s in %s" %
                                      (dirent, path, commit.hex[:8]))
                    return None
            else:
                self.logger.debug("        %s not a tree in %s" %
                                  (tree_or_blob, commit.hex[:8]))
                return None
        return tree_or_blob
266980
def repository(namespace, name, branch='master'):
    ''''''
    with TemporaryDirectory() as download_path:
        old_directory = str(pwd()).strip()
        try:
            git.clone('https://github.com/{0}/{1}.git'.format(namespace, name), download_path)
            cd(download_path)
            git.fetch('origin', branch)
            git.checkout(branch)
            yield (download_path, git('rev-parse', 'HEAD'), redis.Dict(key="{0}.{1}".format(namespace, name)))
        except ErrorReturnCode_128:
            mkdir(download_path)
            yield (None, None, None)
        cd(old_directory)
683234
def branch(self):
        """"""
        result = get_branch(repo=self.repo)
        if result is None:
            result = get_travis_branch()
        return result