#!/bin/bash FILE=/home/foo/file.ext TASK=T12345 USER=foo PASSWORD=s3cr3t SKIP=(foo bar/boom baz) # space-delimited list for project in `curl -s https://gerrit.wikimedia.org/r/projects/?type=CODE | tail -n+2 | jq --raw-output 'keys[]'`; do if [[ " ${SKIP[@]} " =~ " ${project} " ]]; then continue fi dir=${project//\//_} filename=`basename "$FILE"` repo="https://$USER:$PASS@gerrit.wikimedia.org/r/a/$project" mkdir $dir cd $dir echo "==> $project" git clone --depth 1 $repo . || { cd .. && echo "**ERROR*** in $project"; continue; } if [[ -f $FILE ]]; then continue fi cp "$FILE" . \ && git add "$filename" \ && git commit -m' Add '"$filename"' Bug: '$TASK' Change-Id: I'`cat /dev/urandom | base64 | tr -dc 'a-f0-9' | head -c40` \ && git push $repo HEAD:refs/for/`git rev-parse --abbrev-ref HEAD`%topic=coc,submit && cd .. \ && rm -rf $dir \ || { cd .. && echo "**ERROR*** in $project"; } done;