Page MenuHomePhabricator
Paste P5546

Add a file to every repo
ActivePublic

Authored by Tgr on Jun 6 2017, 9:52 AM.
#!/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;

Event Timeline

Tgr created this paste.Jun 6 2017, 9:52 AM
Tgr updated the paste's language from autodetect to bash.
Tgr edited the content of this paste. (Show Details)Jun 9 2017, 10:42 AM