Freeze your git vendors with submodules and a little bash.

blov · · 596 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Git submodules make for a great what to freeze vendors:</p> <pre><code> go list -f &#39;{{range $imp := .Imports}}{{printf &#34;%s\n&#34; $imp}}{{end}}&#39; ./... \ | awk -F&#39;[/]&#39; &#39;/[.]/ {printf &#34;%s/%s/%s\n&#34;,$1,$2,$3}&#39; \ | sort -u \ | xargs -I REPO -n1 -P1 echo git submodule add -f https://REPO vendor/REPO </code></pre> <p><a href="https://github.com/nicerobot/git-freeze" rel="nofollow">git-freeze</a> implements the above.</p> <p>Note: If you&#39;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&#39;s integration with updates without cluttering your repo with copies of other packages.</p> <hr/>**评论:**<br/><br/>dominikh: <pre><p><a href="https://www.reddit.com/r/golang/comments/492w0u/do_you_like_go_get_want_to_vendor_your_code/d0opzll" rel="nofollow">https://www.reddit.com/r/golang/comments/492w0u/do_you_like_go_get_want_to_vendor_your_code/d0opzll</a></p></pre>nicerobot: <pre><p>Sorry, that&#39;s wrong. You summed it up in the second paragraph. If you&#39;re actually afraid of the repo disappearing, saving all the code into a vendor folder isn&#39;t the right approach. It&#39;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.</p></pre>Fwippy: <pre><p>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. <code>&gt;=1.4</code>)</p></pre>nicerobot: <pre><p>Yea, unfortunately, there&#39;s only so far tools can go before significantly benefiting from having language support. Enhancements to the <code>import</code> 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&#39;d just enhance it myself.</p></pre>

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

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