# Copies the COMMON master flake8 configuration file into each
# and every lambda directory (excluding those with leading _
# in their name, e.g. __pycache__) and adds it to Git.
for dir in ../lambdas/*; do
    if [[ -d "$dir" && "$(basename "$dir")" != _* ]]; then
        if [[ ! -f "$dir/.flake8" ]] || ! cmp -s .flake8 "$dir/.flake8"; then
            cp .flake8 "$dir"
            git add "$dir/.flake8"
            echo "Copied and staged .flake8 to $dir (content differs or file is missing)"
        else
            echo "Skipping $dir (file exists and content is identical)"
        fi
    fi
done