adk deploy ignores .gitignore patterns that start with **/

未關閉
#8,294 1 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 3 天內回覆

@surajksharma07 已經在處理了。

開始於 2026年11月23日。

  • #8296 來自 @AshfaqueAhbab —— 未關閉

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
25/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
停滯
技術堆疊
gcp, python
領域
cli

研究方向

Start with _get_ignore_patterns_func in cli/cli_deploy.py, which passes the ignore patterns to shutil.ignore_patterns. Leading **/ patterns contain a slash and never match a bare file or folder name, so the stripping logic there needs to handle them. Check the gitignore-style cases listed in the issue, including the trailing slash in **/__pycache__/. Done means copying an agent folder with that function leaves out node_modules and __pycache__ directories. A linked pull request (#8296) is already open, so check it before starting.

由索引模型根據 Issue 內容生成。

描述

🔴 Required Information

Describe the Bug:
adk deploy reads .gitignore, .gcloudignore and .ae_ignore from the agent folder, but patterns with a leading **/ never match anything. Paths such as **/node_modules or **/__pycache__/ are common in these files, and the matching files and folders are still copied into the deployment.

_get_ignore_patterns_func in cli/cli_deploy.py passes the patterns to shutil.ignore_patterns, which compares them with file and folder names, not paths. **/node_modules contains a /, so it never equals a name. Root-anchored patterns such as /.venv already have their leading / stripped for the same reason.

Steps to Reproduce:

  1. In an agent folder, create node_modules/pkg/index.js, sub/__pycache__/x.pyc and a .gitignore with:
    **/node_modules
    **/__pycache__/
    
  2. Run adk deploy cloud_run (or agent_engine / gke), or copy the folder the way the deploy commands do:
    import shutil
    from google.adk.cli.cli_deploy import _get_ignore_patterns_func
    
    shutil.copytree("agent", "out", ignore=_get_ignore_patterns_func("agent"))
    
  3. Look at what was copied.

Expected Behavior:
node_modules and __pycache__ are left out, as they are by git and gcloud.

Observed Behavior:
Both are copied: out/node_modules/pkg/index.js and out/sub/__pycache__/x.pyc exist.

Environment Details:

  • ADK Library Version: 2.15.0 (main at 2b90353)
  • Desktop OS: Linux
  • Python Version: 3.12.13

Model Information:

  • Are you using LiteLLM: No
  • Which model is being used: N/A

🟡 Optional Information

Additional Context:
In .gitignore syntax, a leading **/ means "in any directory", which is what a plain name already matches, so stripping it gives the same result. Patterns with a / in the middle (like docs/build) also never match today, but I'd leave those alone, since approximating them could drop files the agent needs.

How often has this issue occurred?:

  • Always (100%)
主要語言
Python
星號
22.3k
分支
4.4k
平均合併
1 天 2 小時
30 天內合併 PR
6

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

google/adk-python 的其他 Issue

查看 google/adk-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。