File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717exit_code=0
1818
19- # Get list of newly added files using diff-filter=A
20- # Using process substitution to avoid subshell and handle spaces in filenames
19+ get_added_files () {
20+ if git rev-parse --is-inside-work-tree > /dev/null 2>&1 ; then
21+ git diff --cached --name-only --diff-filter=A
22+ elif jj root > /dev/null 2>&1 ; then
23+ jj diff --summary 2> /dev/null | awk ' /^A / {print $2}'
24+ elif hg root > /dev/null 2>&1 ; then
25+ hg status --added --no-status 2> /dev/null
26+ elif g4 info > /dev/null 2>&1 ; then
27+ g4 opened 2> /dev/null | awk ' / - add / {print $1}' | sed ' s/#.*//'
28+ elif p4 info > /dev/null 2>&1 ; then
29+ p4 opened 2> /dev/null | awk ' / - add / {print $1}' | sed ' s/#.*//'
30+ fi
31+ }
32+
2133while read -r file; do
2234 # Check if file is not empty (happens if no new files)
2335 if [[ -n " $file " ]]; then
24- if [[ " $file " == src/ google/adk/* .py ]]; then
36+ if [[ " $file " == * /google/adk/ * .py ]] || [[ " $file " == google/adk/* .py ]]; then
2537 filename=$( basename " $file " )
2638 if [[ ! " $filename " == _* ]]; then
2739 echo " Error: New Python file '$file ' must have a '_' prefix."
@@ -32,6 +44,6 @@ while read -r file; do
3244 fi
3345 fi
3446 fi
35- done < <( git diff --cached --name-only --diff-filter=A )
47+ done < <( get_added_files )
3648
3749exit $exit_code
You can’t perform that action at this time.
0 commit comments