github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/contrib/cirrus/success.sh (about) 1 #!/bin/bash 2 3 set -e 4 5 source $(dirname $0)/lib.sh 6 7 req_env_var CIRRUS_BRANCH CIRRUS_REPO_FULL_NAME CIRRUS_BASE_SHA CIRRUS_CHANGE_IN_REPO CIRRUS_CHANGE_MESSAGE 8 9 cd $CIRRUS_WORKING_DIR 10 11 if [[ "$CIRRUS_BRANCH" =~ "pull" ]] 12 then 13 echo "Retrieving latest HEADS and tags" 14 git fetch --all --tags 15 echo "Finding commit authors for PR $CIRRUS_PR" 16 unset NICKS 17 if [[ -r "$AUTHOR_NICKS_FILEPATH" ]] 18 then 19 SHARANGE="${CIRRUS_BASE_SHA}..${CIRRUS_CHANGE_IN_REPO}" 20 EXCLUDE_RE='merge-robot' 21 EMAILCSET='[:alnum:]-+_@.' 22 AUTHOR_NICKS=$(egrep -v '(^[[:space:]]*$)|(^[[:space:]]*#)' "$AUTHOR_NICKS_FILEPATH" | sort -u) 23 # Depending on branch-state, it's possible SHARANGE could be _WAY_ too big 24 MAX_NICKS=10 25 # newline separated 26 GITLOG="git log --format='%ae'" 27 COMMIT_AUTHORS=$($GITLOG $SHARANGE || $GITLOG -1 HEAD | \ 28 tr --delete --complement "$EMAILCSET[:space:]" | \ 29 egrep -v "$EXCLUDE_RE" | \ 30 sort -u | \ 31 tail -$MAX_NICKS) 32 33 for c_email in $COMMIT_AUTHORS 34 do 35 c_email=$(echo "$c_email" | tr --delete --complement "$EMAILCSET") 36 echo -e "\tExamining $c_email" 37 NICK=$(echo "$AUTHOR_NICKS" | grep -m 1 "$c_email" | \ 38 awk --field-separator ',' '{print $2}' | tr -d '[[:blank:]]') 39 if [[ -n "$NICK" ]] 40 then 41 echo -e "\t\tFound $c_email -> $NICK in $(basename $AUTHOR_NICKS_FILEPATH)" 42 else 43 echo -e "\t\tNot found in $(basename $AUTHOR_NICKS_FILEPATH), using e-mail username." 44 NICK=$(echo "$c_email" | cut -d '@' -f 1) 45 fi 46 if ! echo "$NICKS" | grep -q "$NICK" 47 then 48 echo -e "\tUsing nick $NICK" 49 NICKS="${NICKS:+$NICKS, }$NICK" 50 else 51 echo -e "\tNot re-adding duplicate nick $NICK" 52 fi 53 done 54 fi 55 56 unset MENTION_PREFIX 57 [[ -z "$NICKS" ]] || \ 58 MENTION_PREFIX="$NICKS: " 59 60 URL="https://github.com/$CIRRUS_REPO_FULL_NAME/pull/$CIRRUS_PR" 61 PR_SUBJECT=$(echo "$CIRRUS_CHANGE_MESSAGE" | head -1) 62 ircmsg "${MENTION_PREFIX}Cirrus-CI testing successful for PR '$PR_SUBJECT': $URL" 63 else 64 URL="https://cirrus-ci.com/github/containers/libpod/$CIRRUS_BRANCH" 65 ircmsg "Cirrus-CI testing branch $(basename $CIRRUS_BRANCH) successful: $URL" 66 fi