Add script to manage gitignore anchors
Added scripts which comment and uncomment out patterns relating to
generated files.
Signed-off-by: Agathiyan Bragadeesh <agabra02@e127300.arm.com>
diff --git a/scripts/gitignore_add_generated_files.sh b/scripts/gitignore_add_generated_files.sh
new file mode 100644
index 0000000..27c3480
--- /dev/null
+++ b/scripts/gitignore_add_generated_files.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -eu
+
+GITIGNORES=$(find . -name ".gitignore")
+
+for GITIGNORE in $GITIGNORES; do
+ IN_GEN_BLOCK=false
+ while read -r line; do
+ if [ "$line" = "###START_COMMENTED_GENERATED_FILES###" ]; then
+ IN_GEN_BLOCK=true
+ echo "###START_GENERATED_FILES###"
+ elif [ "$line" = "###END_COMMENTED_GENERATED_FILES###" ]; then
+ IN_GEN_BLOCK=false
+ echo "###END_GENERATED_FILES###"
+ elif $IN_GEN_BLOCK ; then
+ echo "${line:1}"
+ else
+ echo "$line"
+ fi
+ done <$GITIGNORE > "$GITIGNORE.tmp"
+ mv "$GITIGNORE.tmp" $GITIGNORE
+done