@@ -316,6 +316,62 @@ check_license() {
316316 fi
317317}
318318
319+ # Check that files listed in install.yaml project_files/global_files contain exactly one #ddev-generated
320+ check_ddev_generated () {
321+ local install_yaml=" install.yaml"
322+
323+ local line entry count in_section section dir_file
324+ local list_item_re=' ^[[:space:]]*-[[:space:]]+(.*)'
325+
326+ for section in project_files global_files; do
327+ in_section=false
328+ while IFS= read -r line; do
329+ # Detect section header
330+ if [[ " $line " == " ${section} :" ]]; then
331+ in_section=true
332+ continue
333+ fi
334+
335+ [[ " $in_section " != " true" ]] && continue
336+
337+ # A top-level YAML key (starts with a letter) ends the section
338+ [[ " $line " =~ ^[a-zA-Z] ]] && break
339+
340+ # Match non-commented list entries with any indentation: "- <value>"
341+ [[ " $line " =~ $list_item_re ]] || continue
342+ entry=" ${BASH_REMATCH[1]} "
343+
344+ [[ -z " $entry " ]] && continue
345+
346+ # Skip entries with environment variable interpolation (can't resolve at check time)
347+ [[ " $entry " =~ \$\{ ]] && continue
348+
349+ # For directories, check all files inside recursively
350+ if [[ -d " $entry " ]]; then
351+ while IFS= read -r -d ' ' dir_file; do
352+ count=$( grep -c " #ddev-generated" " $dir_file " 2> /dev/null) || count=0
353+ if [[ " $count " -eq 0 ]]; then
354+ actions+=(" $dir_file (in directory $entry listed in install.yaml $section ) does not contain '#ddev-generated'" )
355+ elif [[ " $count " -gt 1 ]]; then
356+ actions+=(" $dir_file (in directory $entry listed in install.yaml $section ) should contain exactly one '#ddev-generated', found $count occurrences" )
357+ fi
358+ done < <( find " $entry " -type f -print0 2> /dev/null)
359+ continue
360+ fi
361+
362+ [[ ! -f " $entry " ]] && continue
363+
364+ count=$( grep -c " #ddev-generated" " $entry " 2> /dev/null) || count=0
365+
366+ if [[ " $count " -eq 0 ]]; then
367+ actions+=(" $entry is listed in install.yaml ($section ) but does not contain '#ddev-generated'" )
368+ elif [[ " $count " -gt 1 ]]; then
369+ actions+=(" $entry is listed in install.yaml ($section ) should contain exactly one '#ddev-generated', found $count occurrences" )
370+ fi
371+ done < " $install_yaml "
372+ done
373+ }
374+
319375# Check .gitattributes
320376check_gitattributes () {
321377 local gitattributes=" .gitattributes"
@@ -415,6 +471,9 @@ run_checks() {
415471 # Check install.yaml for conditions
416472 check_install_yaml
417473
474+ # Check #ddev-generated in files listed in install.yaml
475+ check_ddev_generated
476+
418477 # Check docker-compose.*.yaml for conditions
419478 check_docker_compose_yaml
420479
0 commit comments