Skip to content

Instantly share code, notes, and snippets.

@lukego
Last active August 29, 2015 14:03
Show Gist options
  • Save lukego/1606dc5a9fc494bd84c9 to your computer and use it in GitHub Desktop.
Save lukego/1606dc5a9fc494bd84c9 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Mandatory Parameters:
# EVENTS_IN: Directory to read incoming events
# EVENTS_OUT: Directory to write accepted events
#
# Optional Parameters:
# PROJECT: Project name (regex fragment)
# EVENTS_SKIP: Directory to write skipped events
accept=0
skip=0
for event in $(ls -1tr ${EVENTS_IN?}); do
f="${EVENTS_IN?}/$event"
if grep -q -e "^ *\"project\": \"${PROJECT}" $f &&
grep -q -e "^ *\"comment\": \"recheck (no )* bug" \
-e "^ *\"type\": \"patchset-created\"" $f; then
echo "Accepted $event"
mv $f ${EVENTS_OUT?}
accept=$[$accept + 1]
else
[ -d "${EVENTS_SKIP}" ] && mv $f ${EVENTS_SKIP} || rm $f
skip=$[$skip + 1]
fi
done
echo "accepted: $accept skipped: $skip"
#!/usr/bin/env bash
# Parameters:
# SSH_USER: username on review.openstack.org
# EVENT_DIR: Directory where gerrit events will be recorded.
ssh -p 29418 ${SSH_OPTS} ${SSH_USER?}@review.openstack.org gerrit stream-events |
(while read -n 102400 line; do
id=$(uuidgen)
echo "$line" | python -mjson.tool > ${EVENT_DIR?}/$id
echo "Wrote $id"
done)
#!/usr/bin/env bash
# Mandatory Parameters:
# SSH_USER: username on review.openstack.org
# COMMENT: Started with PASSED or FAILED.
# CHANGESET
#
# Optional Parameters:
# NO_NEGATIVE: Vote 0 instead of -1. (During debug.)
vote="0"
if echo ${COMMENT?} | grep -i '^passed'; then
vote="+1"
elif echo ${COMMENT?} | grep -i '^failed'; then
vote="-1"
fi
ssh -p 29418 ${SSH_OPTS} ${SSH_USER?}@review.openstack.org \
gerrit vote --code-review ${vote} --message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment