操作 Git 資料庫的Ruby開源項目:Ruby/Git

jopen 11年前發布 | 18K 次閱讀 Git 版本控制系統

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

項目主頁:http://www.baiduhome.net/lib/view/home/1375952973968

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!