# Path: valohai_cli/git.py
# def get_current_commit(directory: str) -> str:
#     """
#     (Try to) get the current commit of the Git working copy in `directory`.
#     :param directory: Directory path.
#     :return: Commit SHA
#     """
#     return check_git_output(['git', 'rev-parse', 'HEAD'], directory).strip().decode()


from subprocess import check_call
from valohai_cli.git import get_current_commit



def test_get_current_commit(tmpdir):
    dir = str(tmpdir)
    check_call('git init', cwd=dir, shell=True)
    check_call('git config user.name Robot', cwd=dir, shell=True)
    check_call('git config user.email robot@example.com', cwd=dir, shell=True)
    tmpdir.join('test').write_text('test', 'utf8')
    check_call('git add .', cwd=dir, shell=True)

# Path: valohai_cli/git.py
# def get_current_commit(directory: str) -> str:
#     """
#     (Try to) get the current commit of the Git working copy in `directory`.
#     :param directory: Directory path.
#     :return: Commit SHA
#     """
#     return check_git_output(['git', 'rev-parse', 'HEAD'], directory).strip().decode()


# Path: tests/test_git.py
from subprocess import check_call
from valohai_cli.git import get_current_commit




def test_get_current_commit(tmpdir):
    dir = str(tmpdir)
    check_call('git init', cwd=dir, shell=True)
    check_call('git config user.name Robot', cwd=dir, shell=True)
    check_call('git config user.email robot@example.com', cwd=dir, shell=True)
    tmpdir.join('test').write_text('test', 'utf8')
    check_call('git add .', cwd=dir, shell=True)

    check_call('git commit -mtest', cwd=dir, shell=True)