# Path: pybombs/utils/subproc.py
# READ_TIMEOUT = 0.1 # s
# def check_output(*args, **kwargs):
# def get_child_pids(pid):
# def kill_process_tree(process, pid=None):
# def run_with_output_processing(p, o_proc, event, cleanup=None):
#     def enqueue_output(stdout_data, stdout_queue, stderr_data, stderr_queue):
#     def poll_queue(q):
# def _process_thread(event, args, kwargs):
#     def elevate_command(args, elevate_pre_args):
#     def pretty_print_cmd(args):
# def monitor_process(args, **kwargs):
# def match_output(command, pattern, match_key=None, **kwargs):


import os
import re
from pybombs.fetchers.base import FetcherBase
from pybombs.utils import subproc
from pybombs.pb_exception import PBException
from pybombs.utils import vcompare
            from pybombs import gitcache_manager
#
"""
git fetcher functions
"""


def parse_git_url(url, args):
    """
    - If a git rev is given in the URL, split that out and put it into the args

    Look for format:
        <URL>@<commit|rev|tag>

    <commit|rev|tag> cannot contain a ':','/','@' or whitespace.
    """
    mobj = re.match(r"""(.*)@                #The url before the @.
                        ((?:(?![\/:@\s]).)+$)#If the @ is followed by any of /:@ or whitespace
                                             #then it's not '@commit', it is 'token@', non-capture.
                    """, url, re.VERBOSE)
    if mobj:
        url, args['gitrev'] = mobj.groups()
    return url, args

def get_git_version():
    """
    Return the currently installed git version as a string.
    """
    try:
        return re.search(
            r'[0-9.]+',

# Path: pybombs/utils/subproc.py
# READ_TIMEOUT = 0.1 # s
# def check_output(*args, **kwargs):
# def get_child_pids(pid):
# def kill_process_tree(process, pid=None):
# def run_with_output_processing(p, o_proc, event, cleanup=None):
#     def enqueue_output(stdout_data, stdout_queue, stderr_data, stderr_queue):
#     def poll_queue(q):
# def _process_thread(event, args, kwargs):
#     def elevate_command(args, elevate_pre_args):
#     def pretty_print_cmd(args):
# def monitor_process(args, **kwargs):
# def match_output(command, pattern, match_key=None, **kwargs):


# Path: pybombs/fetchers/git.py
import os
import re
from pybombs.fetchers.base import FetcherBase
from pybombs.utils import subproc
from pybombs.pb_exception import PBException
from pybombs.utils import vcompare
            from pybombs import gitcache_manager

#
"""
git fetcher functions
"""


def parse_git_url(url, args):
    """
    - If a git rev is given in the URL, split that out and put it into the args

    Look for format:
        <URL>@<commit|rev|tag>

    <commit|rev|tag> cannot contain a ':','/','@' or whitespace.
    """
    mobj = re.match(r"""(.*)@                #The url before the @.
                        ((?:(?![\/:@\s]).)+$)#If the @ is followed by any of /:@ or whitespace
                                             #then it's not '@commit', it is 'token@', non-capture.
                    """, url, re.VERBOSE)
    if mobj:
        url, args['gitrev'] = mobj.groups()
    return url, args

def get_git_version():
    """
    Return the currently installed git version as a string.
    """
    try:
        return re.search(
            r'[0-9.]+',

            subproc.check_output(['git', '--version'])