# Path: mod/log.py
# RED = '\033[1;31m'
# GREEN = '\033[1;32m'
# YELLOW = '\033[1;33m'
# BLUE = '\033[1;36m'
# DEF = '\033[0;0m'
# def error(msg, fatal=True) :
# def warn(msg) :
# def ok(item, status) :
# def failed(item, status) :
# def optional(item, status) :
# def info(msg) :
# def colored(color, msg) :


import re
import subprocess
from mod import log
"""wrapper for some git commands"""


name = 'git'
platforms = ['linux', 'osx', 'win']
optional = False
not_found = "git not found in path, can't happen(?)"

# default git clone depth
clone_depth = 10

#-------------------------------------------------------------------------------
def check_exists(fips_dir=None) :
    """test if git is in the path
    
    :returns:   True if git is in the path
    """
    try :
        subprocess.check_output(['git', '--version'])
        return True
    except (OSError, subprocess.CalledProcessError) :
        return False

#-------------------------------------------------------------------------------
def check_exists_with_error():
    """checks if git exists, and if not throws a fatal error"""
    if not check_exists():

# Path: mod/log.py
# RED = '\033[1;31m'
# GREEN = '\033[1;32m'
# YELLOW = '\033[1;33m'
# BLUE = '\033[1;36m'
# DEF = '\033[0;0m'
# def error(msg, fatal=True) :
# def warn(msg) :
# def ok(item, status) :
# def failed(item, status) :
# def optional(item, status) :
# def info(msg) :
# def colored(color, msg) :


# Path: mod/tools/git.py
import re
import subprocess
from mod import log

"""wrapper for some git commands"""


name = 'git'
platforms = ['linux', 'osx', 'win']
optional = False
not_found = "git not found in path, can't happen(?)"

# default git clone depth
clone_depth = 10

#-------------------------------------------------------------------------------
def check_exists(fips_dir=None) :
    """test if git is in the path
    
    :returns:   True if git is in the path
    """
    try :
        subprocess.check_output(['git', '--version'])
        return True
    except (OSError, subprocess.CalledProcessError) :
        return False

#-------------------------------------------------------------------------------
def check_exists_with_error():
    """checks if git exists, and if not throws a fatal error"""
    if not check_exists():

        log.error("git not found, please run and fix './fips diag tools'")