Created
March 3, 2014 19:19
-
-
Save friedmud/9332544 to your computer and use it in GitHub Desktop.
pre_devel_to_master moosebuild
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
# Go to where the MOOSE repo was cloned | |
cd $DEVEL_REPO_DIR | |
# Make sure there is nothing hanging around | |
git reset HEAD --hard | |
# clean it | |
git clean -xfd | |
# Check out the devel branch (note, we might already be there, that's ok) | |
git co devel | |
# Delete the "test" branch in case it still exists | |
git branch -D test | |
# Update the remotes | |
git fetch origin | |
# Create a branch to work with (we'll delete this later) | |
# $sha in this case is the revision of devel we need to test | |
git co -b test $sha | |
# Check for a ticket reference | |
TICKET_REFERENCE=`git log $base_sha..$sha | perl -ne 'print if /#\d{3,}/'` | |
# Check for whitespace | |
WHITESPACE_FILES=`find . \( -name '*.[Chi]' -or -name '*.py' \) -print0 | xargs -0 perl -nle 'if ($ARGV ne $oldargv && /\s+$/) { print "\t$ARGV"; $oldargv=$ARGV }'` | |
# Check for banned keywords | |
BANNED_KEYWORDS=`find . \( -name '*.[Chi]' -or \( -name "contrib" -or -name "libmesh" \) -prune -and -type f \) -print0 | xargs -0 perl -nle 'if ($ARGV ne $oldargv && (/std::cout|std::cerr/ || /sleep\s*\(/)) { print "\t$ARGV"; $oldargv=$ARGV }'` | |
# Printing decisions... | |
one_failed=0 | |
if [ "x$TICKET_REFERENCE" == "x" ]; then | |
one_failed=1 | |
else | |
one_passed=1 | |
fi | |
if [ "x$WHITESPACE_FILES" != "x" ]; then | |
one_failed=1 | |
else | |
one_passed=1 | |
fi | |
if [ "x$BANNED_KEYWORDS" != "x" ]; then | |
one_failed=1 | |
else | |
one_passed=1 | |
fi | |
#Print information about the passing tests | |
if [ $one_passed == 1 ]; then | |
printf "\n\n##########################################################################\n" | |
if [ "x$TICKET_REFERENCE" != "x" ]; then | |
printf "INFO: Your patch contains a valid ticket reference.\n" | |
fi | |
if [ "x$WHITESPACE_FILES" == "x" ]; then | |
printf "INFO: Your patch contains no trailing whitespace.\n" | |
fi | |
if [ "x$BANNED_KEYWORDS" == "x" ]; then | |
printf "INFO: Your patch contains no banned keywords.\n" | |
fi | |
printf "##########################################################################\n\n" | |
fi | |
#Print information about failed tests | |
if [ $one_failed == 1 ]; then | |
printf "\n##########################################################################" | |
if [ "x$TICKET_REFERENCE" == "x" ]; then | |
printf "\nERROR: Your patch does not contain a valid ticket reference! (i.e. #1234)\n" | |
git log $base_sha..$sha | |
fi | |
if [ "x$WHITESPACE_FILES" != "x" ]; then | |
printf "\nERROR: The following files contain trailing whitespace after applying your patch:\n${WHITESPACE_FILES}\n" | |
printf "\nRun the following command in the base of your moose directory to cleanup whitespace:\n" | |
printf 'find . \( -name '*.[Chi]' -or -name '*.py' -or \( -name "contrib" -or -name "libmesh" \) -prune -and -type f \) -print0 | xargs -0 perl -pli -e "s/\s+$//"\n' | |
fi | |
if [ "x$BANNED_KEYWORDS" != "x" ]; then | |
printf "\nERROR: The following files contain banned keywords (std::cout, std::cerr, sleep):\n${BANNED_KEYWORDS}\n" | |
fi | |
printf "##########################################################################\n\n" | |
fi | |
# Clean up in the case of bad merge | |
git reset HEAD --hard | |
# Go back to the devel branch then delete this one | |
git co devel | |
git branch -D test | |
# Return the return code | |
exit $one_failed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment