#!/bin/sh

FACTORY=$(git diff --cached packaging/SuSE/samba.changes | tail -n +5)
SLE15SP6=$(git diff --cached packaging/SuSE/samba.changes.sle15-sp6 | tail -n +5)

if [ "${FACTORY}" != "${SLE15SP6}" ]; then
    echo
    echo "The commit failed because changelogs differ."
    echo
    echo "Please ensure that packaging/SuSE/samba.changes modifications"
    echo "are also applied to:"
    echo "  - packaging/SuSE/samba.changes.sle15-sp6"
    exit 1
fi

FACTORY=$(git diff --cached packaging/SuSE/baselibs.conf | tail -n +5)
SLE15SP6=$(git diff --cached packaging/SuSE/baselibs.conf.sle15-sp6 | tail -n +5)

if [ "${FACTORY}" != "${SLE15SP6}" ]; then
    echo
    echo "The commit failed because baselibs.conf(s) differ."
    echo
    echo "Please ensure that packaging/SuSE/baselibs.conf modifications"
    echo "are also applied to:"
    echo "  - packaging/SuSE/baselibs.conf.sle15-sp6"
    exit 1
fi

FACTORY=$(git diff --cached packaging/SuSE/baselibs.conf | tail -n +5)
SLE15SP6=$(git diff --cached packaging/SuSE/baselibs.conf.sle15-sp6 | tail -n +5)

if [ "${FACTORY}" != "${SLE15SP6}" ]; then
    echo
    echo "The commit failed because baselibs.conf(s) differ."
    echo
    echo "Please ensure that packaging/SuSE/baselibs.conf modifications"
    echo "are also applied to:"
    echo "  - packaging/SuSE/baselibs.conf.sle15-sp6"
    exit 1
fi

FACTORY=$(git diff --cached packaging/SuSE/samba.spec | tail -n +5)
SLE15SP6=$(git diff --cached packaging/SuSE/samba.spec.sle15-sp6 | tail -n +5)

if [ "${FACTORY}" != "${SLE15SP6}" ]; then
    echo
    echo "The commit failed because samba.specs(s) differ."
    echo
    echo "Please ensure that packaging/SuSE/samba.spec modifications"
    echo "are also applied to:"
    echo "  - packaging/SuSE/samba.spec.sle15-sp6"
    exit 1
fi

exit 0
