# Path: valohai_cli/exceptions.py
# class NoCommit(ValueError, CLIException):
#     color = 'yellow'
# 
#     def __init__(self, directory: str) -> None:
#         self.directory = directory
#         super().__init__(f'{directory} has no commits')
# 
# class NoGitRepo(CLIException):
#     color = 'yellow'
# 
#     def __init__(self, directory: str) -> None:
#         self.directory = directory
#         super().__init__(f'{directory} is not a Git repository')


import os
import subprocess
from typing import Sequence
from valohai_cli.exceptions import NoCommit, NoGitRepo



def check_git_output(args: Sequence[str], directory: str) -> bytes:
    try:
        return subprocess.check_output(
            args=args,
            cwd=directory,
            shell=False,
            stderr=subprocess.STDOUT,
            env=dict(os.environ, LC_ALL='C'),
        )
    except subprocess.CalledProcessError as cpe:
        if cpe.returncode == 128:
            output_text = cpe.output.decode().lower()
            if 'not a git repository' in output_text:
                raise NoGitRepo(directory)
            if 'bad revision' in output_text:

# Path: valohai_cli/exceptions.py
# class NoCommit(ValueError, CLIException):
#     color = 'yellow'
# 
#     def __init__(self, directory: str) -> None:
#         self.directory = directory
#         super().__init__(f'{directory} has no commits')
# 
# class NoGitRepo(CLIException):
#     color = 'yellow'
# 
#     def __init__(self, directory: str) -> None:
#         self.directory = directory
#         super().__init__(f'{directory} is not a Git repository')


# Path: valohai_cli/git.py
import os
import subprocess
from typing import Sequence
from valohai_cli.exceptions import NoCommit, NoGitRepo




def check_git_output(args: Sequence[str], directory: str) -> bytes:
    try:
        return subprocess.check_output(
            args=args,
            cwd=directory,
            shell=False,
            stderr=subprocess.STDOUT,
            env=dict(os.environ, LC_ALL='C'),
        )
    except subprocess.CalledProcessError as cpe:
        if cpe.returncode == 128:
            output_text = cpe.output.decode().lower()
            if 'not a git repository' in output_text:
                raise NoGitRepo(directory)
            if 'bad revision' in output_text:

                raise NoCommit(directory)