Rugged 是一个 Git 的 Ruby 开发包,使用 libgit2 API
$ gem
install
rugged
require
'rugged'
# => #<Rugged::Repository:2228536260 {path: "path/to/my/repository/.git/"}>
Rugged::Repository.discover(
"/Users/me/projects/repo/lib/subdir/"
)
# => "/Users/me/projects/repo/.git/"
# Does the given SHA1 exist in this repository?
repo.exists?(
'07b44cbda23b726e5d54e2ef383495922c024202'
)
# => true
# Boolean repository state values:
repo.bare?
# => false
repo.empty?
# => true
repo.head_orphan?
# => false
repo.head_detached?
# => false
# Path Accessors
repo.path
# => "path/to/my/repository/.git/"
repo.workdir
# => "path/to/my/repository/"
# The HEAD of the repository.
ref = repo.head
# => #<Rugged::Reference:2228467240 {name: "refs/heads/master", target: "07b44cbda23b726e5d54e2ef383495922c024202"}>
# From the returned ref, you can also access the `name` and `target`:
ref.name
# => "refs/heads/master"
ref.target
# => "07b44cbda23b726e5d54e2ef383495922c024202"
# Reading an object
object = repo.read(
'a0ae5566e3c8a3bddffab21022056f0b5e03ef07'
)
# => #<Rugged::OdbObject:0x109a64780>
object.len
# => 237
object.Data
# => "tree 76f23f186076fc291742816721ea8c3e95567241\nparent 8e3c5c52b8f29da0adc7e8be8a037cbeaea6de6b\nauthor VICEnt Mart\303\255 <tanoku@Gmail.com> 1333859005 +0200\ncommitter Vicent Mart\303\255 <tanoku@gmail.com> 1333859005 +0200\n\nAdd `Repository#blob_at`\n"
object.type
# => :commit
发布于 2016-03-11 01:28:54 | 92 次阅读
发布于 2016-03-03 00:27:37 | 155 次阅读
发布于 2016-02-16 23:30:52 | 93 次阅读
发布于 2015-08-14 00:00:16 | 172 次阅读
发布于 2015-06-29 23:56:56 | 110 次阅读
发布于 2015-06-27 01:29:46 | 85 次阅读
发布于 2015-05-18 23:27:03 | 110 次阅读
发布于 2015-03-10 04:32:19 | 190 次阅读
发布于 2015-01-18 23:47:27 | 177 次阅读
发布于 2014-12-19 00:22:32 | 147 次阅读
发布于 2014-11-19 00:56:26 | 155 次阅读