1414# limitations under the License.
1515
1616
17+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
18+ REPO_ROOT=" $( cd " $SCRIPT_DIR /.." && pwd) "
19+ ADK_REAL_ROOT=$( dirname " $( realpath " $REPO_ROOT /src/google/adk/__init__.py" ) " )
20+ EXCLUDE_TESTS=" $ADK_REAL_ROOT /tests"
21+ EXCLUDE_WORKSPACE=" $ADK_REAL_ROOT /open_source_workspace"
22+ EXCLUDE_CONTRIBUTING=" $ADK_REAL_ROOT /contributing"
23+
1724exit_code=0
1825
1926get_added_files () {
@@ -33,11 +40,17 @@ get_added_files() {
3340while read -r file; do
3441 # Check if file is not empty (happens if no new files)
3542 if [[ -n " $file " ]]; then
36- # Match only files in the package source (src/google/adk/) to avoid false
37- # positives in environments (e.g., monorepos) where the entire repository
38- # root is nested under a 'google/adk/' directory structure.
39- if [[ " $file " == * /src/google/adk/* .py ]] || [[ " $file " == src/google/adk/* .py ]]; then
40- filename=$( basename " $file " )
43+ # Match only files in the package source (resolving symlinks to support both
44+ # open-source and internal layouts) and exclude tests/workspace to avoid
45+ # false positives.
46+ abs_file=$( realpath " $file " 2> /dev/null || echo " " )
47+ if [[ -n " $abs_file " ]] && \
48+ [[ " $abs_file " == " $ADK_REAL_ROOT " /* ]] && \
49+ [[ " $abs_file " != " $EXCLUDE_TESTS " /* ]] && \
50+ [[ " $abs_file " != " $EXCLUDE_WORKSPACE " /* ]] && \
51+ [[ " $abs_file " != " $EXCLUDE_CONTRIBUTING " /* ]] && \
52+ [[ " $abs_file " == * .py ]]; then
53+ filename=$( basename " $abs_file " )
4154 if [[ ! " $filename " == _* ]]; then
4255 echo " Error: New Python file '$file ' must have a '_' prefix."
4356 echo " All new Python files in src/google/adk/ must be private by default."
0 commit comments