coder / coder/envbuilder

Support SCP-like parent URLs with relative submodules

Đang mở
#492 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
envbuilder Feature
Ngôn ngữ chính
Go
Star
300
Fork
64
Merge trung bình
20 phút
Pull request đã merge (30 ngày)
1

Mô tả

## Problem

When the parent repository uses an SCP-like URL (e.g., `git@github.com:org/repo.git`) and a submodule is configured with a relative path (e.g., `../other/submodule.git`), envbuilder cannot resolve the submodule URL.

Currently this returns an error:
```
relative submodule URL "../other/submodule.git" cannot be resolved: parent URL "git@github.com:org/repo.git" uses SCP-like syntax which is not supported for relative submodule resolution
```

## Background

Go's `net/url.Parse()` cannot properly parse SCP-like URLs - they have no scheme and use `:` as a path separator instead of `/`.

We've built a custom `ResolveSubmoduleURL` function to handle relative submodule paths because go-git's native implementation has bugs with:
- HTTPS URLs losing slashes when using `filepath.Dir()`
- Multiple relative paths (`../../submodule.git`) not resolving correctly

## Workaround

Users can configure submodules with absolute URLs instead of relative paths.

## Proposed Solution

Add SCP-like URL handling to `ResolveSubmoduleURL`:
1. Detect SCP-like parent URLs using the existing `scpLikeURLRegex`
2. Parse into user, host, and path components
3. Apply relative path resolution to the path component
4. Reconstruct the SCP-like URL

Alternatively, use go-git's `transport.NewEndpoint()` which can parse SCP-like URLs, but this needs careful testing to ensure it doesn't reintroduce the bugs we worked around.

## Related/Blocker

- PR #485: feat: add git submodule support

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu bằng cách tìm ResolveSubmoduleURL và scpLikeURLRegex hiện có. Đọc cách xử lý đường dẫn tương đối và so sánh với hành vi của transport.NewEndpoint() trong go-git, sau đó bổ sung coverage cho các URL cha dạng SCP và các đường dẫn submodule tương đối. Hoàn thành khi URL được báo cáo được phân giải mà không gặp lỗi hiện tại, đồng thời các trường hợp HTTPS hiện có và các trường hợp có nhiều đường dẫn tương đối vẫn tiếp tục hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
git, go
Lĩnh vực
devtools
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
56/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.