aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-19 12:46:32 -0500
committerCraig Jennings <c@cjennings.net>2026-04-19 12:46:32 -0500
commit8d4495d4bc62fc4695617e6d5cc62b47a6d43820 (patch)
tree1280b9321c5eded2a753e9b5df384042333ad86c /scripts
parent217079ec84c8c7081fe4c27494915fe873d99f68 (diff)
downloadrulesets-8d4495d4bc62fc4695617e6d5cc62b47a6d43820.tar.gz
rulesets-8d4495d4bc62fc4695617e6d5cc62b47a6d43820.zip
fix(install): don't duplicate gitignore header on re-run
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/install-lang.sh7
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/install-lang.sh b/scripts/install-lang.sh
index 2ee4aa7..4097bde 100755
--- a/scripts/install-lang.sh
+++ b/scripts/install-lang.sh
@@ -79,6 +79,7 @@ fi
# 4. .gitignore — append missing lines (deduped, skip comments)
if [ -f "$SRC/gitignore-add.txt" ]; then
touch "$PROJECT/.gitignore"
+ header="# --- $LANG ruleset ---"
added=0
while IFS= read -r line || [ -n "$line" ]; do
# Skip blank lines and comments in the source file
@@ -86,9 +87,9 @@ if [ -f "$SRC/gitignore-add.txt" ]; then
case "$line" in \#*) continue ;; esac
# Only add if not already present
if ! grep -qxF "$line" "$PROJECT/.gitignore"; then
- # If this is the first line we're adding, prepend a header
- if [ "$added" -eq 0 ]; then
- printf '\n# --- %s ruleset ---\n' "$LANG" >> "$PROJECT/.gitignore"
+ # Prepend header only if it isn't already in the file
+ if [ "$added" -eq 0 ] && ! grep -qxF "$header" "$PROJECT/.gitignore"; then
+ printf '\n%s\n' "$header" >> "$PROJECT/.gitignore"
fi
echo "$line" >> "$PROJECT/.gitignore"
added=$((added + 1))