Tag: libgit2

如何为libgit2提交Ruby绑定

有没有人知道如何使用libgit2的ruby绑定(’rugged’gem)创建提交? 我已经尝试了所有可以找到的示例,在libgit2使用指南和坚固的gem github页面上,并且没有用于创建或编辑提交的示例正在运行。 这有助于弄清楚到目前为止如何提交,除了它是针对libgit2本身而不是ruby绑定。 http://librelist.com/browser//libgit2/2011/2/19/initing-a-repository-adding-files-to-the-index-and-committing/#d94ce8df18ff0202ce904180286a4a85 当我尝试提交时,按照Rugged Github页面上的步骤,我得到了这个; pry(main)> Rugged::Commit.create( repo, :author=>author, :message=>”Hello world\n\n”, :committer=>author, :parents=>parents, :tree=>tree ) TypeError: wrong argument type nil (expected String) 当我尝试遵循libgit2使用指南时,它基本上是为了获取提交,然后使用commit.message= like命令编辑它,但随后我得到noMethodErrors,因为没有’message =’方法。 libgit2使用指南: http ://libgit2.github.com/api.html 坚固耐用的文档0: http : //rubydoc.info/gems/rugged/0.16.0/frames Rugged Github页面: https : //github.com/libgit2/rugged 编辑:我如何重现这一点; http://pastebin.com/wnta8FWm Edit_n + 1:我也尝试过使用树的sha而不是Rugged :: Tree对象 x=Rugged::Commit.create( repo, :author=>author, :message=>”Hello world\n\n”, :committer=>author, :parents=>parents, :tree=>tree.oid ) […]

使用Rugged / libgit2创建提交时如何更新工作目录?

我正在尝试使用以下测试脚本创建一个坚固的提交: require “rugged” r = Rugged::Repository.new(“.”) index = r.index index.read_tree(r.references[“refs/heads/master”].target.tree) blob = r.write(“My test”, :blob) index.add(:oid => blob, :path => “test.md”, :mode => 0100644) tree = index.write_tree parents = [r.references[“refs/heads/master”].target].compact actor = {:name => “Actor”, :email => “actor@bla”} options = { :tree => tree, :parents => parents, :committer => actor, :message => “message”, :update_ref => […]

我如何使用rugged来创建和提交命令行中的文件?

我正在尝试使用坚固的做一些非常简单的事情:创建并提交一个文件,使存储库处于与执行相同的状态: git init echo “blah blah blah” > blah.txt git add blah.txt git commit -m “write blah.txt” 留下git status打印 On branch master nothing to commit, working directory clean 我使用的代码改编自坚固的回购自述文件 ,归结为: name = “blah.txt” repo = Rugged::Repository.init_at dir File.open File.join(dir, name), ‘w’ do |f| f.write content end oid = Rugged::Blob.from_workdir repo, name index = repo.index index.add(:path […]