1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#!/bin/sh
#
# ARGS: 1:remote
#
BRANCH=coverity_scan
if [ -z "$1" ] ; then
cat <<EOF
Usage: $0 REMOTE
This script triggers a coverity build by pushing the current code to
the '$BRANCH' branch.
It copies the current (master) branch over the '$BRANCH' branch,
then copies 'coverity.travis.yml' over '.travis.yml' and force-pushes
the new branch.
You obviously must have commit rights on the repository, so this is
a maintainer-only script, unless you are pushing to your own fork.
Example:
$0 origin
EOF
exit 1
fi
REMOTE=$1
set -e
if [ -z "$NOTIFICATION_EMAIL" ] ; then
NOTIFICATION_EMAIL=$(git config user.email)
if [ -z "$NOTIFICATION_EMAIL" ] ; then
echo "No notification email address set."
exit 1
fi
fi
if [ $(git rev-parse --abbrev-ref HEAD) != 'master' ] ; then
cat <<EOF
Please switch to the master branch before running this script.
EOF
exit 1
fi
if git describe --dirty | grep -q dirty ; then
cat <<EOF
Please clean up your dirty workspace before running this script.
EOF
exit 1
fi
echo "NOTIFICATION_EMAIL: $NOTIFICATION_EMAIL"
if git branch | grep $BRANCH ; then
echo "Deleting local coverity_scan branch..."
git branch -D $BRANCH
fi
git branch $BRANCH $REMOTE/master
git checkout -f $BRANCH
sed "s|{NOTIFICATION_EMAIL}|$NOTIFICATION_EMAIL|" coverity.travis.yml > .travis.yml
git add .travis.yml
git commit -m 'Copy coverity.travis.yml -> .travis.yml for coverity build.'
git push -f $REMOTE $BRANCH
git checkout master
echo 'Finished.'
|