coder / coder/envbuilder

Support SCP-like parent URLs with relative submodules

未关闭
#492 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
envbuilder Feature
主要语言
Go
星标
300
派生
64
平均合并
20 分钟
30 天内合并 PR
1

描述

## 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

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start by locating ResolveSubmoduleURL and the existing scpLikeURLRegex. Read the relative-path handling and compare it with go-git's transport.NewEndpoint() behavior, then add coverage for SCP-like parent URLs and relative submodule paths. Done means the reported URL resolves without the current error while existing HTTPS and multiple-relative-path cases continue to work.

由索引模型根据 Issue 内容生成。

评估

技术栈
git, go
领域
devtools
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
56/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。