# Path: shopify_python/git_utils.py
# class GitUtilsException(Exception):
# class _CustomPylintReporter(text.ColorizedTextReporter):
# def _remote_origin_master(git_repo):
# def _modified_in_branch(git_repo, other_ref):
# def _file_is_python(path):
# def changed_python_files_in_tree(root_path):
# def autopep_files(files, max_line_length):
#     def __init__(self):
#     def handle_message(self, msg):
# def pylint_files(files, **kwargs):


import os
import py  # pylint: disable=unused-import
import pytest
import git  # pylint: disable=unused-import
from git import repo
from shopify_python import git_utils
    file_name = os.path.join(new_repo.working_dir, 'new_file')
    open(str(file_name), 'wb').close()
    new_repo.index.add([str(file_name)])
    new_repo.index.commit("initial commit")
    new_repo.remote('origin').push('master')

    return new_repo


def test_detects_changed_python_files(main_repo, python_file, python_script):
    # type: (repo.Repo, str, str) -> None

    main_repo.create_head('foo').checkout()
    main_repo.index.add([python_file, python_script])
    main_repo.index.commit("adding python files")

    changed_files = git_utils.changed_python_files_in_tree(main_repo.working_dir)
    assert sorted(changed_files) == [
        os.path.basename(python_script),
        os.path.basename(python_file),
    ]


def test_doesnt_include_changed_nonpython_files(main_repo, python_file, non_python_file):
    # type: (repo.Repo, str, str) -> None

    main_repo.create_head('foo').checkout()
    main_repo.index.add([python_file, non_python_file])
    main_repo.index.commit("adding mixed files")


# Path: shopify_python/git_utils.py
# class GitUtilsException(Exception):
# class _CustomPylintReporter(text.ColorizedTextReporter):
# def _remote_origin_master(git_repo):
# def _modified_in_branch(git_repo, other_ref):
# def _file_is_python(path):
# def changed_python_files_in_tree(root_path):
# def autopep_files(files, max_line_length):
#     def __init__(self):
#     def handle_message(self, msg):
# def pylint_files(files, **kwargs):


# Path: tests/shopify_python/test_git_utils.py
import os
import py  # pylint: disable=unused-import
import pytest
import git  # pylint: disable=unused-import
from git import repo
from shopify_python import git_utils

    file_name = os.path.join(new_repo.working_dir, 'new_file')
    open(str(file_name), 'wb').close()
    new_repo.index.add([str(file_name)])
    new_repo.index.commit("initial commit")
    new_repo.remote('origin').push('master')

    return new_repo


def test_detects_changed_python_files(main_repo, python_file, python_script):
    # type: (repo.Repo, str, str) -> None

    main_repo.create_head('foo').checkout()
    main_repo.index.add([python_file, python_script])
    main_repo.index.commit("adding python files")

    changed_files = git_utils.changed_python_files_in_tree(main_repo.working_dir)
    assert sorted(changed_files) == [
        os.path.basename(python_script),
        os.path.basename(python_file),
    ]


def test_doesnt_include_changed_nonpython_files(main_repo, python_file, non_python_file):
    # type: (repo.Repo, str, str) -> None

    main_repo.create_head('foo').checkout()
    main_repo.index.add([python_file, non_python_file])
    main_repo.index.commit("adding mixed files")


    changed_files = git_utils.changed_python_files_in_tree(main_repo.working_dir)