<commit_before># -*- coding: utf-8 -*-

"""
legit.core
~~~~~~~~~~

Not much.
"""
import os

from clint import resources


__version__ = '0.0.1'

def find_above(*names):
    """Attempt to locate given file by searching parent dirs."""

    path = '.'

    while os.path.split(os.path.abspath(path))[1]:
        for name in names:
            joined = os.path.join(path, name)
            if os.path.exists(joined):
                return os.path.abspath(joined)
        path = os.path.join('..', path)


def path_to_repo():
    """Returns the path the current repo, if there is one."""

    return find_above('.git')


def get_available_branches():
    """Returns a list of available branches in the repo."""

    return ('master', 'develop')


def get_current_branch():
    """Returns the active available branches in the repo."""

    return 'develop'


def sync_repo():
    """Git fetch. Auto branch of remotes? pull --rebase, push."""
    pass


print path_to_repo()
# Init Resources

resources.init('kennethreitz', 'legit')
resources.user.write('config.ini', "we'll get there.")<commit_msg>actually get a branch list<commit_after># -*- coding: utf-8 -*-

"""
legit.core
~~~~~~~~~~

This module provides the basic functionality of legit.
"""

from clint import resources
from pygit2 import Repository

from .helpers import find_path_above



__version__ = '0.0.1'
__author__ = '<NAME>'
__license__ = 'TBD'


def get_repo(path_to_repo):
    return Repository(path_to_repo)


def path_to_repo():
    """Returns the path the current repo, if there is one."""

    return find_path_above('.git')


def get_available_branches():
    """Returns a list of available branches in the repo."""

    return ('master', 'develop')


def get_current_branch():
    """Returns the active available branches in the repo."""

    return 'develop'


def switch_to_branch(branch):
    pass


def sync_repo():
    """Git fetch. Auto branch of remotes? pull --rebase, push."""
    pass


def get_branches():
    branches = dict(local=list(), remote=list(), current=None)

    repo = get_repo(path_to_repo())

    for branch in repo.listall_references():
        if branch.startswith('refs/heads/'):
            branch_name = branch.replace('refs/heads/', '')
            branches['local'].append(branch_name)
        elif branch.startswith('refs/remotes/'):
            branch_name = branch.replace('refs/remotes/', '')
            branches['remote'].append(branch_name)
        else:
            # print branch
            pass

    current_branch = repo.lookup_reference('HEAD').resolve().name
    current_branch = current_branch.replace('refs/heads/', '')

    branches['current'] = current_branch

    return branches




print get_branches()
# print
# print dir(repo)

# Init Resources

resources.init('kennethreitz', 'legit')
resources.user.write('config.ini', "we'll get there.")
{'fraction_non_alphanumeric': 0.14405301709103593, 'fraction_numerical': 0.003487966515521451, 'mean_word_length': 3.223858615611193, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2168801', 'n_tokens_mistral': 902, 'n_tokens_neox': 860, 'n_words': 243}