forked from trilinos/Trilinos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
user="GITHUB_USER_NAME" | ||
fork="trilinos" | ||
repo="Trilinos" | ||
mainBranch="develop" | ||
|
||
approval_string="Approved for push" | ||
tokenfile=~/.githubOAuth/token | ||
|
||
TMPFILE=/tmp/.ac$$ | ||
|
||
usage="Usage: isawesome.sh <PR>, where <PR> is a valid pull request number for $fork/$repo, " | ||
|
||
# Ensure that we were only passed a single command line argument. | ||
if [[ $# -ne 1 ]]; then | ||
echo $usage | ||
exit 1 | ||
fi | ||
|
||
# Ensure that the argument was an integer. | ||
re='^[0-9]+$' | ||
if ! [[ $1 =~ $re ]]; then | ||
echo $usage | ||
echo "$1 must be an integer." | ||
exit 2 | ||
fi | ||
|
||
# Get the details from that pull request. | ||
pr=$1 | ||
token=$(cat $tokenfile) | ||
h="'Authorization: token $token'" | ||
curl -i -H $h https://api.github.com/repos/$fork/$repo/pulls/$pr >$TMPFILE 2> /dev/null | ||
|
||
# Ensure the pull request number was valid. | ||
if grep "message.*Not Found" $TMPFILE > /dev/null; then | ||
echo $usage | ||
echo "It looks like pull request $pr does not exist in $fork/$repo." | ||
exit 3 | ||
fi | ||
|
||
# Get the SHA of the PR | ||
SHA=`grep -A 3 '"head"' $TMPFILE | grep sha |cut -f2 -d: | sed 's/[", ]//g'` | ||
|
||
# Make sure everyone knows this PR is awesome | ||
CMD=$(echo curl -i -H \'Authorization: token $token\' -d \'{\"state\": \"success\" , \"description\": \"This code is awesome\", \"context\": \"awesome\"}\' https://api.github.com/repos/trilinos/Trilinos/statuses/$SHA) | ||
eval $CMD > $TMPFILE 2> /dev/null | ||
|
||
if grep state $TMPFILE > /dev/null; then | ||
echo "Auto-awesome succeeded" | ||
else | ||
echo "Auto-awesome FAILED"; exit 3 | ||
fi | ||
|
||
rm -f $TMPFILE |