#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
 (c) 2018 - Copyright Red Hat Inc

 Authors:
   Patrick Uiterwijk <puiterwijk@redhat.com>

"""

from __future__ import unicode_literals, absolute_import

import os
import sys
# The following is only needed if you did not install pagure
# as a python module (for example if you run it from a git clone).
#sys.path.insert(0, '/path/to/pagure/')

if os.environ.get("internal_no_hooks", False):
    # we do this check before any pagure machinery is imported
    # and initialized to make sure this is very fast (used
    # when pushing code from original repos to forks)
    sys.exit(0)

if "PAGURE_CONFIG" not in os.environ and os.path.exists(
    "/etc/pagure/pagure.cfg"
):
    os.environ["PAGURE_CONFIG"] = "/etc/pagure/pagure.cfg"

import pagure.lib
from pagure.hooks import run_hook_file

hooktype = os.path.basename(sys.argv[0])

run_hook_file(hooktype)
