新手问题 git ls-files -z 问题

lanyatou · 2014年08月12日 · 最后由 lanyatou 回复于 2014年08月13日 · 2839 次阅读

在项目中写自己的 gem 的时候,用的时

bundle  gem   gem_name 

来创建 gem 骨架的,这个时候我们会根据自己的需求来在 gem_name 文件夹中创建很多的.rb 文件,并在 gem_name.rb 文件中 require 这些文件,但是我发现必须执行

git add .  
git commit 

之后再执行

gem build  gem_name.gemspec 

这样才能将我新添加的文件打包到一个新的 version 中。因为总是要手动执行这些命令,所以觉得跟手动在 gem_name.gemspec 中修改 spec.files 没啥两样了,如果真是这样的话,还要git ls-files -z.split("\x0") 干啥。或者说是我不知道它的用法。在 railscasts 中看到这句话:One interesting part of this file are the file attributes towards the end of the file. Each of these is determined at runtime by using the git ls-files command by using git to determine the files that will be included in the gem.没太看明白是啥意思,希望高手多多指点

这样只是为了方便吧。当你新加了一个文件之后不用再去修改 gemspec 中的 spec.files。你只要通过 git add 和 git commit 把文件加到 git 仓库中就行了。你要手工修改当然也是可以的。不过这世界就是懒人多啊。

@AlphaLiu 好吧,说服我了。。。。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号