Freeze your git vendors with submodules and a little bash.

blov · 2016-03-05 17:25:46 · 686 次点击    
这是一个分享于 2016-03-05 17:25:46 的资源,其中的信息可能已经有所发展或是发生改变。

Git submodules make for a great what to freeze vendors:

    go list -f '{{range $imp := .Imports}}{{printf "%s\n" $imp}}{{end}}' ./... \
    | awk -F'[/]' '/[.]/ {printf "%s/%s/%s\n",$1,$2,$3}' \
    | sort -u \
    | xargs -I REPO -n1 -P1 echo git submodule add -f https://REPO vendor/REPO

git-freeze implements the above.

Note: If you're actually afraid of repo(s) disappearing, fork the repo(s) and import and vendor your fork. Using submodule is still valid and provides a consistent mechanism for vendoring as well as retaining a version trail and update/merge history for both vendor submodules and the parent's integration with updates without cluttering your repo with copies of other packages.


评论:

dominikh:

https://www.reddit.com/r/golang/comments/492w0u/do_you_like_go_get_want_to_vendor_your_code/d0opzll

nicerobot:

Sorry, that's wrong. You summed it up in the second paragraph. If you're actually afraid of the repo disappearing, saving all the code into a vendor folder isn't the right approach. It's better to fork the repo and vendor your fork, for which submodule is still valid. The point is, submodules provide a consistent mechanism for vendoring.

Fwippy:

Awesome, this looks pretty cool. If go authors ever start using semver for their packages, it might be handy to also have a little bit of code that identifies commits that satisfy certain version ranges (i.e. >=1.4)

nicerobot:

Yea, unfortunately, there's only so far tools can go before significantly benefiting from having language support. Enhancements to the import declaration specification would be a huge win for dependency management. And it can be enhanced without any breaking changes. I wish I had more time to contribute and I'd just enhance it myself.


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

686 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传