# 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
        """
        args = args or {}
        self.log.debug("Using url {0}".format(url))
        cwd = os.getcwd()
        src_dir = os.path.join(dest, dirname)
        self.log.trace("Switching cwd to: {0}".format(src_dir))
        os.chdir(src_dir)
        if args.get('gitrev'):
            # If we have a rev or tag specified, fetch, then checkout.
            git_cmds = [
                ['git', 'fetch', '--tags', '--all', '--prune'],
                ['git', 'checkout', '--force', args.get('gitrev')],
            ]
        elif args.get('gitbranch'):
            # Branch is similar, only we make sure we're up to date
            # with the remote branch
            git_cmds = [
                ['git', 'fetch', '--tags', '--all', '--prune'],
                ['git', 'checkout', '--force', args.get('gitbranch')],
                ['git', 'reset', '--hard', '@{u}'],
            ]
        else:
            # Without a git rev, all we can do is try and pull
            git_cmds = [
                ['git', 'pull', '--rebase'],
            ]
        git_cmds.append(['git', 'submodule', 'update', '--recursive'])
        o_proc = None
        for cmd in git_cmds:
            try:

# 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

        """
        args = args or {}
        self.log.debug("Using url {0}".format(url))
        cwd = os.getcwd()
        src_dir = os.path.join(dest, dirname)
        self.log.trace("Switching cwd to: {0}".format(src_dir))
        os.chdir(src_dir)
        if args.get('gitrev'):
            # If we have a rev or tag specified, fetch, then checkout.
            git_cmds = [
                ['git', 'fetch', '--tags', '--all', '--prune'],
                ['git', 'checkout', '--force', args.get('gitrev')],
            ]
        elif args.get('gitbranch'):
            # Branch is similar, only we make sure we're up to date
            # with the remote branch
            git_cmds = [
                ['git', 'fetch', '--tags', '--all', '--prune'],
                ['git', 'checkout', '--force', args.get('gitbranch')],
                ['git', 'reset', '--hard', '@{u}'],
            ]
        else:
            # Without a git rev, all we can do is try and pull
            git_cmds = [
                ['git', 'pull', '--rebase'],
            ]
        git_cmds.append(['git', 'submodule', 'update', '--recursive'])
        o_proc = None
        for cmd in git_cmds:
            try:

                if subproc.monitor_process(args=cmd, o_proc=o_proc, throw_ex=True) != 0: