Codebase list python-faraday / 2c76757a-134a-421a-9aad-5774e76f570e/main scripts / sanity_check_commit.sh
2c76757a-134a-421a-9aad-5774e76f570e/main

Tree @2c76757a-134a-421a-9aad-5774e76f570e/main (Download .tar.gz)

sanity_check_commit.sh @2c76757a-134a-421a-9aad-5774e76f570e/mainraw · history · blame

#!/bin/sh
# Check that a white branch doesn't contain commits of pink or black
# and a pink branch has no black commits
# Requires setting BRANCH_NAME environment variable
PINK_COMMIT=da7a869e186f61f1b138392734be4eae62cb2e31  # Always redirect to login page when user is logged out
BLACK_COMMIT=ec3dcfbe8955d41125944e82aa084b441c0b9e77  # Fix msg in webshell

if [ $CI_COMMIT_REF_NAME ]; then
   BRANCH_NAME=$CI_COMMIT_REF_NAME
else
   BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
fi

function fail(){
    echo "Branch $BRANCH_NAME contains commit of another version ($1). You shouldn't do that!!!!!!"
    exit 1
}

function check_no_commits(){
    # Check that current branch doesn't contain the commits passed as arguments
    # If it does contain at least one of then, quit the script with a non-zero exit code
    for commit in $*
    do
        git branch --all --contains "$commit" | grep "$BRANCH_NAME" && fail $commit
    done
}

echo current branch $(git rev-parse --abbrev-ref HEAD) should be equal to $BRANCH_NAME
echo $BRANCH_NAME | grep -i white && check_no_commits $PINK_COMMIT $BLACK_COMMIT
echo $BRANCH_NAME | grep -i pink && check_no_commits $BLACK_COMMIT
exit 0