Skip to content

Commit 69baca9

Browse files
committed
fix: preserve repository ignore rules
1 parent 0c75752 commit 69baca9

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎.github/scripts/sync-template.sh‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ prune=false
2727
languages_set=false
2828
features_set=false
2929
package_manager=""
30+
gitignore_backup=""
31+
custom_ignores=""
3032

3133
valid_languages="typescript rust python solidity"
3234
valid_features="ci codeql security test draft-pr release-pr release dependabot"
@@ -57,6 +59,8 @@ workflow_enabled() {
5759

5860
cleanup() {
5961
if [ -n "$temp_dir" ]; then rm -rf "$temp_dir"; fi
62+
if [ -n "$gitignore_backup" ]; then rm -f "$gitignore_backup"; fi
63+
if [ -n "$custom_ignores" ]; then rm -f "$custom_ignores"; fi
6064
}
6165
trap cleanup EXIT
6266

@@ -195,7 +199,28 @@ for file in "${files[@]}"; do
195199
printf 'Would sync %s\n' "$file"
196200
else
197201
mkdir -p "$(dirname "$file")"
198-
cp "$template_file" "$file"
202+
if [ "$file" = .gitignore ] && [ -f "$file" ]; then
203+
# Keep repository-specific ignore rules while refreshing the shared
204+
# baseline. This prevents a template sync from hiding generated files
205+
# or local tooling that only one project uses.
206+
gitignore_backup="$(mktemp)"
207+
custom_ignores="$(mktemp)"
208+
cp "$file" "$gitignore_backup"
209+
cp "$template_file" "$file"
210+
awk 'NR == FNR { seen[$0] = 1; next } NF && !seen[$0] { print }' \
211+
"$template_file" "$gitignore_backup" > "$custom_ignores"
212+
if [ -s "$custom_ignores" ]; then
213+
{
214+
printf '\n# Repository-specific rules\n'
215+
cat "$custom_ignores"
216+
} >> "$file"
217+
fi
218+
rm -f "$gitignore_backup" "$custom_ignores"
219+
gitignore_backup=""
220+
custom_ignores=""
221+
else
222+
cp "$template_file" "$file"
223+
fi
199224
case "$file" in
200225
.githooks/*|.github/scripts/*) chmod +x "$file" ;;
201226
esac

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "repo-foundry",
3-
"version": "0.1.1",
3+
"version": "0.1.2",
44
"description": "A fast, language-aware repository factory for agent-ready workflows, testing, security, and release automation.",
55
"type": "module",
66
"license": "AGPL-3.0-or-later",

0 commit comments

Comments
 (0)