当存储库使用LFS时,如何在本地测试gitlab runner脚本

当存储库使用LFS时,如何在本地测试gitlab runner脚本,git,continuous-integration,gitlab,gitlab-ci-runner,git-lfs,Git,Continuous Integration,Gitlab,Gitlab Ci Runner,Git Lfs,我正在与GitLab跑步者合作,在推之前必须对他们进行本地测试 这可以通过使用 gitlab-runner exec docker testing 而且效果很好 现在,如果存储库使用LFS,这将不再有效,并且会出现如下错误 batch request: missing protocol: "/home/self/workspace/project.git/info/lfs" 这似乎是因为如果使用LFS,您不能将本地文件夹克隆到另一个文件夹 使用git clone--reference有一个

我正在与GitLab跑步者合作,在推之前必须对他们进行本地测试

这可以通过使用

gitlab-runner exec docker testing 
而且效果很好

现在,如果存储库使用LFS,这将不再有效,并且会出现如下错误

batch request: missing protocol: "/home/self/workspace/project.git/info/lfs"
这似乎是因为如果使用LFS,您不能将本地文件夹克隆到另一个文件夹

使用git clone--reference有一个变通方法


但是如何将其应用于gitlab runner呢?

这个疯狂的黑客程序正在发挥作用:

gitlab-runner exec docker testing --pre-clone-script 'set -x; function git {
  if [[ "$1" == "clone" && "$@" != *"--help"* ]]; then
    command git clone "$2" --reference $3 https://user:password@git.example.com.de/path/to/repo.git "$4" "$5" "$6"   
  else
    command git "$@"
  fi
}'
你必须更换的地方

https://user:password@git.example.com.de/path/to/repo.git
通过本地存储库的原始HTTPs URL,包括用户名和密码

这里发生了什么?
我们正在重新定义git clone命令,然后由GitLab运行程序执行该命令并添加reference选项。成功克隆后,其余部分正常运行。

谢谢分享!我试图替换
https://user:password@git.example.com.de/path/to/repo.git
与我的本地git Repository一起使用,它也起到了作用。如果您希望使用本地提交但尚未推送到服务器的lfs文件进行克隆,那么这可能会更好。