Beispiel #1
0
def git_support(fn, command):
    """Resolves git aliases and supports testing for both git and hub."""
    # supports GitHub's `hub` command
    # which is recommended to be used with `alias git=hub`
    # but at this point, shell aliases have already been resolved
    if not is_app(command, 'git', 'hub'):
        return False

    # perform git aliases expansion
    if 'trace: alias expansion:' in command.stderr:
        search = re.search("trace: alias expansion: ([^ ]*) => ([^\n]*)",
                           command.stderr)
        alias = search.group(1)

        # by default git quotes everything, for example:
        #     'commit' '--amend'
        # which is surprising and does not allow to easily test for
        # eg. 'git commit'
        expansion = ' '.join(
            shell.quote(part) for part in shell.split_command(search.group(2)))
        new_script = command.script.replace(alias, expansion)

        command = command.update(script=new_script)

    return fn(command)
Beispiel #2
0
def git_support(fn, command):
    """Resolves git aliases and supports testing for both git and hub."""
    # supports GitHub's `hub` command
    # which is recommended to be used with `alias git=hub`
    # but at this point, shell aliases have already been resolved
    if not is_app(command, 'git', 'hub'):
        return False

    # perform git aliases expansion
    if 'trace: alias expansion:' in command.stderr:
        search = re.search("trace: alias expansion: ([^ ]*) => ([^\n]*)",
                           command.stderr)
        alias = search.group(1)

        # by default git quotes everything, for example:
        #     'commit' '--amend'
        # which is surprising and does not allow to easily test for
        # eg. 'git commit'
        expansion = ' '.join(shell.quote(part)
                             for part in shell.split_command(search.group(2)))
        new_script = command.script.replace(alias, expansion)

        command = command.update(script=new_script)

    return fn(command)
Beispiel #3
0
    def add_app(self, app):
        """

        :param app:
        :return:
        """
        if not is_app(app):
            logger.error('not a app')
            raise Exception()
        app(self)
Beispiel #4
0
 def __init__(self, app, host=None, port=None):
     if is_app(app):
         self.app = MainHandler(app)
     elif isinstance(app, MainHandler):
         self.app = app
     else:
         logger.error('not a app')
         raise Exception()
     self._host = host or '127.0.0.1'
     self._port = port or 8080
     self._socket = self._get_socket(self._host, self._port)