操作 Git 资料库的Ruby开源项目:Ruby/Git
jopen
11年前
Ruby/Git 是一个 Ruby 库可用来创建、操作 Git 资料库。它是通过封装了系统命令调用的方式实现的。
示例代码:
g.with_temp_index do g.read_tree(tree3) # calls self.index.read_tree g.read_tree(tree1, :prefix => 'hi/') c = g.commit_tree('message') # or # t = g.write_tree c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2]) g.branch('branch_name').update_ref(c) g.update_ref(branch, c) g.with_temp_working do # new blank working directory g.checkout g.checkout(another_index) g.commit # commits to temp_index end end g.set_index('/path/to/index') g.with_index(path) do # calls set_index, then switches back after end g.with_working(dir) do # calls set_working, then switches back after end g.with_temp_working(dir) do g.checkout_index(:prefix => dir, :path_limiter => path) # do file work g.commit # commits to index end