fix(git): accept git smart HTTP requests without the .git suffix
ZhenYi committed
Modified chart/values.yaml chart/values.yaml +5 −3 View chart/values.yaml
@@ -278,9 +278,11 @@
278278 className: nginx
279279 host: gitdata.example.com
280280 # githost 路由匹配(仅 controller=nginx 使用)
281 githostPath: "/(.*\\.git)(/|$)"
282 # traefik 用的正则(覆盖 owner/repo.git 与多级 group)
283 githostPathRegexp: "^/.+\\.git(/|$)"
281 githostPath: "^/(.*\\.git)(/|$)|^/[^/]+/[^/]+/(HEAD$|info/|objects/|git-upload-pack|git-receive-pack)"
282 # traefik 用的正则(覆盖 owner/repo.git 与多级 group);同时放行省略 .git 的 git
283 # 协议端点 —— actions/checkout 用 GITHUB_SERVER_URL + GITHUB_REPOSITORY 拼远程地址,
284 # 不带 .git 后缀,只按 *.git 匹配会把它打到 apihost 的 SPA 上。
285 githostPathRegexp: "^/.+\\.git(/|$)|^/[^/]+/[^/]+/(HEAD$|info/|objects/|git-upload-pack|git-receive-pack)"
284286 annotations: {}
285287 tls:
286288 enabled: true
Modified lib/git/src/smart/handler.rs lib/git/src/smart/handler.rs +6 −4 View lib/git/src/smart/handler.rs
@@ -45,10 +45,12 @@
4545 "smart http request received"
4646 );
4747
48 let repo_name = match repo.strip_suffix(".git") {
49 Some(name) if !name.is_empty() => name.to_string(),
50 _ => return SmartError::BadRequest("expected '<repo>.git' in URL".into()).into_response(),
51 };
48 // git 客户端(含 actions/checkout)既可能访问 /<space>/<repo>.git,也可能省略
49 // .git 后缀,两种形态都要落到同一个仓库。
50 let repo_name = repo.strip_suffix(".git").unwrap_or(&repo).to_string();
51 if repo_name.is_empty() {
52 return SmartError::BadRequest("expected '<repo>.git' in URL".into()).into_response();
53 }
5254
5355 let path_lower = path.to_lowercase();
5456 let result: SmartResult<Response> = match (path_lower.as_str(), method.clone()) {