#!{{ python_executable }}
# -*- coding: utf-8 -*-
# copyright: (c) 2020 by Jesse Johnson.
# license: MPL-2.0, see LICENSE for more details.
"""Test git hooks pipeline."""

from git import Repo
from pypyr import log, pipelinerunner

git_repo = Repo('.git', search_parent_directories=True)
git_root_path = git_repo.git.rev_parse('--show-toplevel')

log.logger.set_root_logger(
    log_level={{ log_level }},
    log_path={% if log_path %}'{{ log_path }}'{% else %}None{% endif %}
)

pipelinerunner.main(
    pipeline_name='.git-hooks',
    pipeline_context_input='{{ pipeline_context_input }}',
    working_dir=git_root_path,
    groups=[
        {%- for group in groups -%}
            '{{ group }}'{% if not loop.last %}, {% endif %}
        {%- endfor -%}
    ],
    success_group='{{ success_group }}',
    failure_group='{{ failure_group }}',
)
