|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +function in_names() |
| 5 | +{ |
| 6 | + local name |
| 7 | + for name in "${names[@]}"; do |
| 8 | + [[ $1 != "$name" ]] || return 0 |
| 9 | + done |
| 10 | + return 1 |
| 11 | +} |
| 12 | + |
| 13 | +if ! git rev-parse --verify main >& /dev/null; then |
| 14 | + git fetch origin main |
| 15 | + git branch --track main origin/main |
| 16 | +fi |
| 17 | +IFS=$'\n' names=($(git diff --name-only main)) |
| 18 | +if in_names info/owners.yaml; then |
| 19 | + for name in "${names[@]}"; do |
| 20 | + [[ $name != info/owners.yaml && $name != info/RHMAINTAINERS && |
| 21 | + $name != info/CODEOWNERS ]] || continue |
| 22 | + echo "=======================================================" |
| 23 | + echo "These changes include owners.yaml modifications together with other" |
| 24 | + echo "changes. As a safeguard against mistakes, this is not allowed." |
| 25 | + echo |
| 26 | + echo "If you need to do infrastructure changes please submit two separate" |
| 27 | + echo "merge requests, one for owners.yaml and one for the rest." |
| 28 | + echo "=======================================================" |
| 29 | + exit 1 |
| 30 | + done |
| 31 | +fi |
| 32 | +if in_names info/owners.yaml && \ |
| 33 | + test "$(git config --get owners.warning)" != "false"; then |
| 34 | + echo "=======================================================" |
| 35 | + echo "These changes include owners.yaml modifications. Please" |
| 36 | + echo "review these Merge Request Approval Rules. The Merge Request" |
| 37 | + echo "author must add the appropriate engineers as reviewers on" |
| 38 | + echo "the submitted documentation project Merge Request." |
| 39 | + echo " " |
| 40 | + echo "* Included and excluded file changes can be merged if the" |
| 41 | + echo "MR author is a subsystem maintainer. If the author is not a" |
| 42 | + echo "subsystem maintainer, then the subsystem maintainer must" |
| 43 | + echo "provide an approve." |
| 44 | + echo " " |
| 45 | + echo "* Any MR adding an engineer in a role must be authored by" |
| 46 | + echo "or approved by the added engineer. An additional approve from a" |
| 47 | + echo "subsystem maintainer is required, unless the maintainer is the" |
| 48 | + echo "author of the MR." |
| 49 | + echo " " |
| 50 | + echo "* Any MR removing an engineer in a role must be authored by" |
| 51 | + echo "or approved by the removed engineer, except in the case when" |
| 52 | + echo "the removed engineer is no longer with Red Hat. While removals" |
| 53 | + echo "from roles do not require the approve of the maintainer, MR" |
| 54 | + echo "authors are encouraged to add the maintainer for an approve." |
| 55 | + echo " " |
| 56 | + echo "* Any MR adding or modifying a devel-sst field requires the" |
| 57 | + echo "approval from the subsystem maintainer." |
| 58 | + echo " " |
| 59 | + echo "This warning can be disabled by executing:" |
| 60 | + echo " git config --add owners.warning false" |
| 61 | + echo "=======================================================" |
| 62 | +fi |
| 63 | +if test -n "$(git diff main | grep "^+" | grep "\s\- rhel-sst-null" )"; then |
| 64 | + echo "ERROR: New entries cannot set devel-sst to rhel-sst-null." |
| 65 | + exit 1 |
| 66 | +fi |
| 67 | +if in_names scripts/validSSTNames.go && \ |
| 68 | + test "$(git config --get validsstnames.warning)" != "false"; then |
| 69 | + echo "=======================================================" |
| 70 | + echo "These changes include validSSTNames.go changes. You must ensure" |
| 71 | + echo "the SST names themselves, and the SST name changes in the file are" |
| 72 | + echo "approved by RHEL management. Changes to this file that have" |
| 73 | + echo "not been verified by management will be removed by reverting commits." |
| 74 | + echo " " |
| 75 | + echo "This warning can be disabled by executing:" |
| 76 | + echo " git config --add validsstnames.warning false" |
| 77 | + echo "=======================================================" |
| 78 | +fi |
| 79 | +exit 0 |
0 commit comments