Skip to content

Commit 8ba3806

Browse files
authored
Merge pull request #164 from dockersamples/smarter-gitignore-sdlc
Improve SDLC gitignore handling and ignore GitHub workflows
2 parents 5208e07 + 7efdd28 commit 8ba3806

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

compose.sdlc.yaml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,31 @@ configs:
228228
229229
# Commit the initial Labspace project to the git repo
230230
cd /home/coder/project
231-
echo ".labspace" >> .gitignore
232-
echo "labspace.yaml" >> .gitignore
231+
232+
# Ensure .gitignore exists
233+
touch .gitignore
234+
235+
# Function to safely append to gitignore
236+
add_to_gitignore() {
237+
local entry="$$1"
238+
239+
# Skip if entry already exists
240+
if grep -qxF "$$entry" .gitignore 2>/dev/null; then
241+
return
242+
fi
243+
244+
# Ensure file ends with newline before appending (sed adds it if missing)
245+
sed -i -e '$$a\' .gitignore 2>/dev/null || true
246+
247+
# Now append the entry
248+
echo "$$entry" >> .gitignore
249+
}
250+
251+
# Add entries to gitignore
252+
add_to_gitignore ".labspace"
253+
add_to_gitignore "labspace.yaml"
254+
add_to_gitignore ".github/"
255+
233256
rm -rf .git
234257
git init
235258
git remote add origin [email protected]:moby/demo-app.git

0 commit comments

Comments
 (0)