def cleanup_hash(sha1):
    """
    Checks if a hash is valid. Returns the cleaned up hash if so, else False

    :param sha1: The hash to check
    :return: mixed
    """

    sha1 = sha1.strip()

    try:
        if len(sha1) > 0 and int(sha1, 16) > 0:

            # Hash is valid
            return sha1

    except ValueError:
        print("Invalid sha1 commit: {sha1}".format(sha1=sha1))

    # Hash is invalid
    return False