

def get_branches(local=True, remote_branches=True):
    'Returns a list of local and remote branches.'
    repo_check()
    branches = []
    if remote_branches:
        try:
            for b in remote.refs:
                name = '/'.join(b.name.split('/')[1:])
                if (name not in settings.forbidden_branches):
                    branches.append(Branch(name, is_published=True))
        except (IndexError, AssertionError):
            pass
    if local:
        for b in [h.name for h in repo.heads]:
            if ((b not in [br.name for br in branches]) or (not remote_branches)):
                if (b not in settings.forbidden_branches):
                    branches.append(Branch(b, is_published=False))
    return sorted(branches, key=attrgetter('name'))

dataset/ETHPy150Open kennethreitz/legit/legit/scm.py get_branches/original