github.com/raychaser/docker@v1.5.0/project/getmaintainer.sh (about) 1 #!/usr/bin/env bash 2 set -e 3 4 if [ $# -ne 1 ]; then 5 echo >&2 "Usage: $0 PATH" 6 echo >&2 "Show the primary and secondary maintainers for a given path" 7 exit 1 8 fi 9 10 set -e 11 12 DEST=$1 13 DESTFILE="" 14 if [ ! -d $DEST ]; then 15 DESTFILE=$(basename $DEST) 16 DEST=$(dirname $DEST) 17 fi 18 19 MAINTAINERS=() 20 cd $DEST 21 while true; do 22 if [ -e ./MAINTAINERS ]; then 23 { 24 while read line; do 25 re='^([^:]*): *(.*)$' 26 file=$(echo $line | sed -E -n "s/$re/\1/p") 27 if [ ! -z "$file" ]; then 28 if [ "$file" = "$DESTFILE" ]; then 29 echo "Override: $line" 30 maintainer=$(echo $line | sed -E -n "s/$re/\2/p") 31 MAINTAINERS=("$maintainer" "${MAINTAINERS[@]}") 32 fi 33 else 34 MAINTAINERS+=("$line"); 35 fi 36 done; 37 } < MAINTAINERS 38 break 39 fi 40 if [ -d .git ]; then 41 break 42 fi 43 if [ "$(pwd)" = "/" ]; then 44 break 45 fi 46 cd .. 47 done 48 49 PRIMARY="${MAINTAINERS[0]}" 50 PRIMARY_FIRSTNAME=$(echo $PRIMARY | cut -d' ' -f1) 51 LGTM_COUNT=${#MAINTAINERS[@]} 52 LGTM_COUNT=$((LGTM_COUNT%2 +1)) 53 54 firstname() { 55 echo $1 | cut -d' ' -f1 56 } 57 58 echo "A pull request in $1 will need $LGTM_COUNT LGTM's to be merged." 59 echo "--- $PRIMARY is the PRIMARY MAINTAINER of $1." 60 for SECONDARY in "${MAINTAINERS[@]:1}"; do 61 echo "--- $SECONDARY" 62 done