Repo工具构造无效项目URL问题排查求助
Repo Sync错误拼接Manifest仓库URL与Remote Fetch地址导致权限/不存在异常
背景
我在使用AOSP风格的Repo Manifest时,为了避免每个项目同步都输入HTTPS用户名密码,复刻了原Manifest仓库,将其中的remote fetch地址从HTTPS格式改为SSH格式:
- 原remote配置:
<remote fetch="https://git.githost.org/foo/bar" name="fubar" review="githost.org"/> - 修改后remote配置:
<remote fetch="git@git.githost.org:foo/bar" name="fubar" review="githost.org"/>
已确认的前提:
- 单独克隆
https://git.githost.org/foo/bar/some-repo.git和git@git.githost.org:foo/bar/some-repo.git均成功,URI有效且我拥有访问权限 - 修改前,使用原HTTPS格式的Manifest可以正常执行
repo init和repo sync;修改后,我更新了repo init命令,指向自己的复刻仓库并通过-m指定新的Manifest文件
问题现象与排查过程
执行repo init后运行repo sync,提示仓库不存在或无访问权限,后续排查发现:
- URL拼接异常:我的复刻Manifest仓库地址是
ssh://git@myrepo.com/fubar/manifest.git,Repo尝试拉取项目platform/external/apache-commons-compress时,生成的地址是ssh://git@myrepo.com/fubar/git@git.githost.org:foo/bar/platform/external/apache-commons-compress,而非预期的git@git.githost.org:foo/bar/platform/external/apache-commons-compress.git - 仓库配置错误:查看
.repo/projects/art.git/config中的remote配置,发现URL被错误拼接:
正确的配置应该是:[remote "fubar"] url = ssh://git@myrepo.com/fubar/git@git.githost.org:foo/bar/art[remote "fubar"] url = git@git.githost.org:foo/bar/art - 配置被覆盖:手动修改上述配置为正确内容后,再次执行
repo sync,配置会被重新覆盖为错误的拼接URL
Manifest示例
修改前(可正常同步的HTTPS版本)
<?xml version="1.0" encoding="UTF-8"?> <manifest> <remote fetch="https://git.githost.org/foo/bar" name="fubar" review="githost.org"/> <default remote="fubar" revision="blah"/> <project groups="g1,g2" name="device/generic/art" revision="abcdef1234567890abcdef" upstream="refs/heads/blah"/> </manifest>
修改后(出现问题的SSH版本)
<?xml version="1.0" encoding="UTF-8"?> <manifest> <remote fetch="git@git.githost.org:foo/bar" name="fubar" review="githost.org"/> <default remote="fubar" revision="blah"/> <project groups="g1,g2" name="device/generic/art" revision="abcdef1234567890abcdef" upstream="refs/heads/blah"/> </manifest>
疑问
- 我的操作哪里有误?
- 为什么
repo sync会将remote的fetch URL与Manifest仓库的origin URL拼接在一起? - 是否需要为
repo init添加额外参数来解决这个问题?
内容的提问来源于stack exchange,提问作者copolii
相关产品推荐
相关产品推荐

