Пример #1
0
def fire_rules(execution: Execution):
    if has_unstaged_files():
        raise UnstagedFilesException()

    if is_ahead():
        raise BranchAheadException()

    actions = []

    for action_execution in execution.action.get("execution"):
        do = action_execution.get("do")
        action_from_template = do.get("action")

        LOGGER.info(f"Validando método {action_from_template}...")

        action_class = eval(capitalize_first_letter(action_from_template))

        action = action_class(
            ActionExecution(execution.variables, do.get("parameters"),
                            execution.arguments))

        if not action.is_implemented:
            LOGGER.warn("Método não implementado, favor revisar seu template!")
        else:
            actions.append(action)

    # TODO implementar informativo quando a ação não puder ser executada por
    #  determinado motivo

    for action in actions:
        action.execute()
Пример #2
0
def merge(source: str, target: str, allow_merge_again: bool):
    global GIT_REPO

    if allow_merge_again or not _already_merged(target, source):
        checkout(target)
        pull(target)

        LOGGER.info(
            f"Realizando merge da source {source} com a source {target}...")
        try:
            GIT_REPO.git.merge(source, "--no-ff")
        except GitCommandError:
            raise GitException("O merge gerou conflitos, você precisa "
                               "resolvê-los antes de commitar!")
    else:
        LOGGER.warn(f"O merge da source {source} com a source {target} já "
                    f"foi realizado!")
Пример #3
0
def main(args):
    try:
        px_print("\n-#- P H O E N I X  B E G I N -#-\n")

        LOGGER.info("Iniciando processamento...")

        require_git_repo()
        template = _get_template()

        try:
            validate(instance=template, schema=PHOENIX_SCHEMA)

            LOGGER.info("Validando comando...")
            command = _get_command(args=args, template=template)
            LOGGER.info("Validando ação...")
            action = _get_action(args=args, command=command)
            variables = template.get("variables")
            arguments = args[2:]

            # Create execution object to carry template and
            # arguments through execution
            execution = Execution(
                command=command,
                action=action,
                variables=variables,
                arguments=arguments,
            )

            LOGGER.info("Executando regras...")

            fire_rules(execution)
        except ValidationError as e:
            raise InvalidTemplateException(e.message)
    except PhoenixWarningException as e:
        LOGGER.warn(e.message)
    except PhoenixException as e:
        LOGGER.exception(e.message)
    except Exception as e:
        LOGGER.exception(str(e))

    px_print("\n-#- P H O E N I X  E N D -#-")
Пример #4
0
 def execute(self):
     LOGGER.warn("Not implemented yet!")