rugged 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +21 -0
- data/README.md +290 -0
- data/Rakefile +118 -0
- data/ext/rugged/extconf.rb +9 -0
- data/lib/rugged/index.rb +13 -0
- data/lib/rugged/ribbit.bundle +0 -0
- data/lib/rugged/rugged.bundle +0 -0
- data/lib/rugged/tree.rb +13 -0
- data/lib/rugged/tree_entry.rb +9 -0
- data/lib/rugged/version.rb +3 -0
- data/lib/rugged.rb +5 -0
- data/test/commit_test.rb +36 -0
- data/test/fixtures/testrepo.git/HEAD +1 -0
- data/test/fixtures/testrepo.git/config +6 -0
- data/test/fixtures/testrepo.git/description +1 -0
- data/test/fixtures/testrepo.git/index +0 -0
- data/test/fixtures/testrepo.git/info/exclude +6 -0
- data/test/fixtures/testrepo.git/logs/HEAD +3 -0
- data/test/fixtures/testrepo.git/logs/refs/heads/master +3 -0
- data/test/fixtures/testrepo.git/objects/0c/37a5391bbff43c37f0d0371823a5509eed5b1d +0 -0
- data/test/fixtures/testrepo.git/objects/13/85f264afb75a56a5bec74243be9b367ba4ca08 +0 -0
- data/test/fixtures/testrepo.git/objects/18/1037049a54a1eb5fab404658a3a250b44335d7 +0 -0
- data/test/fixtures/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd +0 -0
- data/test/fixtures/testrepo.git/objects/2d/2eff63372b08adf0a9eb84109ccf7d19e2f3a2 +0 -0
- data/test/fixtures/testrepo.git/objects/36/060c58702ed4c2a40832c51758d5344201d89a +2 -0
- data/test/fixtures/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057 +0 -0
- data/test/fixtures/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045 +2 -0
- data/test/fixtures/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644 +2 -0
- data/test/fixtures/testrepo.git/objects/61/9f9935957e010c419cb9d15621916ddfcc0b96 +0 -0
- data/test/fixtures/testrepo.git/objects/75/057dd4114e74cca1d750d0aee1647c903cb60a +0 -0
- data/test/fixtures/testrepo.git/objects/81/4889a078c031f61ed08ab5fa863aea9314344d +0 -0
- data/test/fixtures/testrepo.git/objects/84/96071c1b46c854b31185ea97743be6a8774479 +0 -0
- data/test/fixtures/testrepo.git/objects/9f/d738e8f7967c078dceed8190330fc8648ee56a +3 -0
- data/test/fixtures/testrepo.git/objects/a4/a7dce85cf63874e984719f4fdd239f5145052f +2 -0
- data/test/fixtures/testrepo.git/objects/a7/1586c1dfe8a71c6cbf6c129f404c5642ff31bd +0 -0
- data/test/fixtures/testrepo.git/objects/a8/233120f6ad708f843d861ce2b7228ec4e3dec6 +0 -0
- data/test/fixtures/testrepo.git/objects/be/3563ae3f795b2b4353bcce3a527ad0a4f7f644 +3 -0
- data/test/fixtures/testrepo.git/objects/c4/7800c7266a2be04c571c04d5a6614691ea99bd +3 -0
- data/test/fixtures/testrepo.git/objects/c4/dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b +0 -0
- data/test/fixtures/testrepo.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 +0 -0
- data/test/fixtures/testrepo.git/objects/f6/0079018b664e4e79329a7ef9559c8d9e0378d1 +0 -0
- data/test/fixtures/testrepo.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92 +0 -0
- data/test/fixtures/testrepo.git/objects/fd/093bff70906175335656e6ce6ae05783708765 +0 -0
- data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx +0 -0
- data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack +0 -0
- data/test/fixtures/testrepo.git/packed-refs +2 -0
- data/test/fixtures/testrepo.git/refs/heads/master +1 -0
- data/test/fixtures/testrepo.git/refs/tags/v0.9 +1 -0
- data/test/fixtures/testrepo.git/refs/tags/v1.0 +1 -0
- data/test/index_test.rb +161 -0
- data/test/lib_test.rb +33 -0
- data/test/object_test.rb +33 -0
- data/test/repo_pack_test.rb +22 -0
- data/test/repo_test.rb +45 -0
- data/test/tag_test.rb +34 -0
- data/test/test_helper.rb +35 -0
- data/test/tree_test.rb +40 -0
- data/test/walker_test.rb +79 -0
- metadata +128 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2010 Scott Chacon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
Rugged - libgit2 bindings in Ruby
|
|
2
|
+
===================================
|
|
3
|
+
|
|
4
|
+
Rugged is a Ruby bindings to the libgit2 linkable C Git library. This is
|
|
5
|
+
for testing and using the libgit2 library in a language that is awesome.
|
|
6
|
+
|
|
7
|
+
INSTALLING AND RUNNING
|
|
8
|
+
========================
|
|
9
|
+
|
|
10
|
+
First you need to install libgit2:
|
|
11
|
+
|
|
12
|
+
$ git clone git://github.com/libgit2/libgit2.git
|
|
13
|
+
$ cd libgit2
|
|
14
|
+
$ make
|
|
15
|
+
$ make install
|
|
16
|
+
|
|
17
|
+
Next, you need to install rake-compiler:
|
|
18
|
+
|
|
19
|
+
$ sudo gem install rake-compiler
|
|
20
|
+
|
|
21
|
+
Now that those are installed, you can install Rugged:
|
|
22
|
+
|
|
23
|
+
$ git clone git://github.com/libgit2/rubbit.git
|
|
24
|
+
$ cd rugged
|
|
25
|
+
$ rake compile
|
|
26
|
+
$ rake test
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
API
|
|
30
|
+
==============
|
|
31
|
+
|
|
32
|
+
There is a general library for some basic Gitty methods. So far, just converting
|
|
33
|
+
a raw sha (20 bytes) into a readable hex sha (40 char).
|
|
34
|
+
|
|
35
|
+
raw = Rugged::Lib.hex_to_raw(hex_sha)
|
|
36
|
+
hex = Rugged::Lib.raw_to_hex(20_byte_raw_sha)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
Repository Access
|
|
40
|
+
-----------------
|
|
41
|
+
|
|
42
|
+
There is a Repository class that you can instantiate with a path.
|
|
43
|
+
This lets you check for objects, read raw object data, write raw object data and
|
|
44
|
+
get a hash (SHA1 checksum) of what contents would be without writing them out.
|
|
45
|
+
You also use it to lookup Git objects from it.
|
|
46
|
+
|
|
47
|
+
Repository is the main repository object that everything
|
|
48
|
+
else will emanate from.
|
|
49
|
+
|
|
50
|
+
repo =
|
|
51
|
+
Rugged::Repository.new(path, git_dir=nil, index_path=nil)
|
|
52
|
+
ctnt, type = repo.read(sha)
|
|
53
|
+
gobj = repo.lookup(sha, type[?]) # optional type argument for checking
|
|
54
|
+
sha = repo.write(content, type)
|
|
55
|
+
sha = repo.hash(content, type)
|
|
56
|
+
bool = repo.exists(sha)
|
|
57
|
+
|
|
58
|
+
If Repository is initialized without `git_dir`, path + '.git' will be assumed
|
|
59
|
+
and path will be assumed to be the working directory. If `path` is a git
|
|
60
|
+
directory, then `git_dir` will be set to that and none of the Rugged functions
|
|
61
|
+
that need a working directory will work. If the `index_path` is not specified,
|
|
62
|
+
the `git_dir` path plus '/index' will be assumed.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
Object Access
|
|
66
|
+
-----------------
|
|
67
|
+
|
|
68
|
+
Object is the main object class - it shouldn't be created directly,
|
|
69
|
+
but all of these methods should be useful in it's derived classes
|
|
70
|
+
|
|
71
|
+
object =
|
|
72
|
+
# Constructor is inherited by all the repository objects
|
|
73
|
+
# 'sha' is the ID of the object;
|
|
74
|
+
# 'repo' is the repository where the object resides
|
|
75
|
+
# If both 'sha' and 'repo' exist, the object will be looked up on
|
|
76
|
+
# the repository and instantiated
|
|
77
|
+
# If the 'sha' ID of the object is missing, the object will be
|
|
78
|
+
# created in memory and can be written later on to the repository
|
|
79
|
+
Rugged::Object(repo, sha)
|
|
80
|
+
obj.sha
|
|
81
|
+
obj.type
|
|
82
|
+
|
|
83
|
+
str = obj.read_raw # read the raw data of the object
|
|
84
|
+
sha = obj.write # write the object to a repository
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
The next classes are for consuming and creating the 4 base
|
|
88
|
+
git object types. just about every method should be able to take
|
|
89
|
+
of each should be able to take a parameter to change the value
|
|
90
|
+
so the object can be re-written slightly differently or no parameter
|
|
91
|
+
to simply read the current value out
|
|
92
|
+
|
|
93
|
+
gobjc =
|
|
94
|
+
Rugged::Commit.new < Rugged::Object
|
|
95
|
+
str = gobjc.message
|
|
96
|
+
str = gobjc.message_short
|
|
97
|
+
str = gobjc.message_body # TODO
|
|
98
|
+
prsn = gobjc.author
|
|
99
|
+
prsn = gobjc.committer
|
|
100
|
+
gobjr = gobjc.tree
|
|
101
|
+
sha = gobjc.tree_sha
|
|
102
|
+
arr = gobjc.parents [*] # TODO
|
|
103
|
+
|
|
104
|
+
gobtg =
|
|
105
|
+
Rugged::Tag.new < Rugged::Object
|
|
106
|
+
gobj = gobtg.target
|
|
107
|
+
int = gobtg.target_type
|
|
108
|
+
str = gobtg.name
|
|
109
|
+
prsn = gobtg.tagger
|
|
110
|
+
str = gobtg.message
|
|
111
|
+
|
|
112
|
+
gobtr =
|
|
113
|
+
Rugged::Tree.new < Rugged::Object
|
|
114
|
+
gobtr.add(ent) # TODO
|
|
115
|
+
gobtr.remove(name) # TODO
|
|
116
|
+
int = gobtr.entry_count
|
|
117
|
+
ent = gobtr.get_entry
|
|
118
|
+
|
|
119
|
+
ent =
|
|
120
|
+
Rugged::TreeEntry.new(attributes, name, sha)
|
|
121
|
+
int = ent.attributes
|
|
122
|
+
str = ent.name
|
|
123
|
+
sha = ent.sha
|
|
124
|
+
gobj = ent.to_object
|
|
125
|
+
|
|
126
|
+
// * Person information is returned as a hash table
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
Commit Walker
|
|
130
|
+
-----------------
|
|
131
|
+
|
|
132
|
+
There is also a Walker class that currently takes a repo object. You can push
|
|
133
|
+
head SHAs onto the walker, then call next to get a list of the reachable commit
|
|
134
|
+
objects, one at a time. You can also hide() commits if you are not interested in
|
|
135
|
+
anything beneath them (useful for a `git log master ^origin/master` type deal).
|
|
136
|
+
|
|
137
|
+
walker =
|
|
138
|
+
Rugged::Walker.new(repo)
|
|
139
|
+
walker.push(hex_sha_interesting)
|
|
140
|
+
walker.hide(hex_sha_uninteresting)
|
|
141
|
+
cmt = walker.next # false if none left
|
|
142
|
+
walker.reset
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
Index/Staging Area
|
|
147
|
+
-------------------
|
|
148
|
+
|
|
149
|
+
We can inspect and manipulate the Git Index as well.
|
|
150
|
+
|
|
151
|
+
# the remove and add functions immediately flush to the index file on disk
|
|
152
|
+
index =
|
|
153
|
+
Rugged::Index.new(repo, path=nil) # TODO: take a repo or a path
|
|
154
|
+
index.refresh # re-read the index file from disk
|
|
155
|
+
int = index.entry_count # count of index entries
|
|
156
|
+
ent = index.get_entry(i/path)
|
|
157
|
+
index.remove(i/path)
|
|
158
|
+
index.add(ientry) # also updates existing entry if there is one
|
|
159
|
+
index.add(path) # create ientry from file in path, update index
|
|
160
|
+
#TODO index.read_tree(gobtr, path='/')
|
|
161
|
+
#TODO index.write_tree
|
|
162
|
+
|
|
163
|
+
ientry =
|
|
164
|
+
Rugged::IndexEntry.new(index, offset)
|
|
165
|
+
str = ientry.path
|
|
166
|
+
time = ientry.ctime
|
|
167
|
+
time = ientry.mtime
|
|
168
|
+
str = ientry.sha
|
|
169
|
+
int = ientry.dev
|
|
170
|
+
int = ientry.ino
|
|
171
|
+
int = ientry.mode
|
|
172
|
+
int = ientry.uid
|
|
173
|
+
int = ientry.gid
|
|
174
|
+
int = ientry.file_size
|
|
175
|
+
int = ientry.flags # (what flags are available?)
|
|
176
|
+
int = ientry.flags_extended # (what flags are available?)
|
|
177
|
+
|
|
178
|
+
Index Status # TODO
|
|
179
|
+
-------------------
|
|
180
|
+
|
|
181
|
+
#TODO index.status # how does the index differ from the work tree and the last commit
|
|
182
|
+
|
|
183
|
+
# >> pp stat
|
|
184
|
+
# [ ['file1', :staged],
|
|
185
|
+
# ['file2', :modified],
|
|
186
|
+
# ['file3', :deleted],
|
|
187
|
+
# ['file4', :untracked],
|
|
188
|
+
# ['file4', :unmerged],
|
|
189
|
+
# ]
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
Ref Management # TODO
|
|
193
|
+
-------------------
|
|
194
|
+
|
|
195
|
+
The RefList class allows you to list, create and delete packed and loose refs.
|
|
196
|
+
|
|
197
|
+
list =
|
|
198
|
+
Rugged::RefList.new(repo)
|
|
199
|
+
ref = list.head # can retrieve and set HEAD with this - returns ref obj or commit obj if detatched
|
|
200
|
+
array = list.list([type]) # type is 'heads', 'tags', 'remotes', 'notes', et
|
|
201
|
+
list.add(oref)
|
|
202
|
+
list.pack
|
|
203
|
+
list.unpack
|
|
204
|
+
|
|
205
|
+
oref =
|
|
206
|
+
Rugged::Ref.new(ref, sha)
|
|
207
|
+
br.name # master
|
|
208
|
+
br.ref # refs/heads/master
|
|
209
|
+
br.type # heads
|
|
210
|
+
br.object
|
|
211
|
+
br.sha
|
|
212
|
+
br.delete
|
|
213
|
+
br.save
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
Config Management # TODO
|
|
217
|
+
------------------------
|
|
218
|
+
|
|
219
|
+
conf =
|
|
220
|
+
Rugged::Config.new(repo)
|
|
221
|
+
hash = conf.list([section])
|
|
222
|
+
val = conf.get(key, [scope])
|
|
223
|
+
bool = conf.set(key, value, [scope]) # scope is 'local'(default), 'global', 'system'
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
Client Transport # TODO
|
|
227
|
+
-----------------------
|
|
228
|
+
|
|
229
|
+
client =
|
|
230
|
+
Rugged::Client.new(repo)
|
|
231
|
+
summry = client.fetch(url, [refs])
|
|
232
|
+
summry = client.push(url, refs)
|
|
233
|
+
refs = client.refs(url) # ls-remote
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
Remote Management # TODO
|
|
237
|
+
------------------------
|
|
238
|
+
|
|
239
|
+
remlist =
|
|
240
|
+
Rugged::RemoteList.new(repo)
|
|
241
|
+
array = remlist.list
|
|
242
|
+
rem = remlist.add(alias, url)
|
|
243
|
+
|
|
244
|
+
rem =
|
|
245
|
+
Rugged::Remote.new(repo)
|
|
246
|
+
summry = rem.fetch([refs])
|
|
247
|
+
summry = rem.push(refs)
|
|
248
|
+
summry = rem.remove(refs)
|
|
249
|
+
bool = rem.delete
|
|
250
|
+
heads = rem.heads
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
Server Transport # TODO
|
|
254
|
+
------------------------
|
|
255
|
+
|
|
256
|
+
server =
|
|
257
|
+
Rugged::Server.new
|
|
258
|
+
server.listen(port = 8080, ip = 0.0.0.0)
|
|
259
|
+
server.export_repo(path/repo)
|
|
260
|
+
server.export_path(path)
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
TODO
|
|
264
|
+
==============
|
|
265
|
+
|
|
266
|
+
I will try to keep this up to date with the working public API available in
|
|
267
|
+
the libgit2 linkable library. Whatever is available there should be here
|
|
268
|
+
as well. The latest libgit2 commit known to link and build successfully will
|
|
269
|
+
be listed in the LIBGIT2_VERSION file.
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
CONTRIBUTING
|
|
273
|
+
==============
|
|
274
|
+
|
|
275
|
+
Fork libgit2/rugged on GitHub, make it awesomer (preferably in a branch named
|
|
276
|
+
for the topic), send a pull request.
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
AUTHORS
|
|
280
|
+
==============
|
|
281
|
+
|
|
282
|
+
* Scott Chacon <schacon@gmail.com>
|
|
283
|
+
* Vicent Marti <tanoku@gmail.com>
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
LICENSE
|
|
287
|
+
==============
|
|
288
|
+
|
|
289
|
+
MIT. See LICENSE file.
|
|
290
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# stolen largely from defunkt/mustache
|
|
2
|
+
require 'rake/testtask'
|
|
3
|
+
require 'rake/rdoctask'
|
|
4
|
+
require 'rake/extensiontask'
|
|
5
|
+
|
|
6
|
+
Rake::ExtensionTask.new('rugged') do |r|
|
|
7
|
+
r.lib_dir = 'lib/rugged'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Helpers
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
def command?(command)
|
|
15
|
+
system("type #{command} > /dev/null")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
#
|
|
20
|
+
# Tests
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
task :default => :test
|
|
24
|
+
|
|
25
|
+
if command? :turn
|
|
26
|
+
desc "Run tests"
|
|
27
|
+
task :test do
|
|
28
|
+
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
|
|
29
|
+
sh "turn test/*_test.rb #{suffix}"
|
|
30
|
+
end
|
|
31
|
+
else
|
|
32
|
+
Rake::TestTask.new do |t|
|
|
33
|
+
t.libs << 'lib'
|
|
34
|
+
t.pattern = 'test/**/*_test.rb'
|
|
35
|
+
t.verbose = false
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if command? :kicker
|
|
40
|
+
desc "Launch Kicker (like autotest)"
|
|
41
|
+
task :kicker do
|
|
42
|
+
puts "Kicking... (ctrl+c to cancel)"
|
|
43
|
+
exec "kicker -e rake test lib"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
desc "Update the libgit2 SHA"
|
|
48
|
+
task :libgit do
|
|
49
|
+
sha = `git --git-dir=../libgit2/.git rev-parse HEAD`
|
|
50
|
+
File.open("LIBGIT2_VERSION", 'w') do |f|
|
|
51
|
+
f.puts "# git --git-dir=../libgit2/.git rev-parse HEAD"
|
|
52
|
+
f.puts sha
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
#
|
|
58
|
+
# Ron
|
|
59
|
+
#
|
|
60
|
+
|
|
61
|
+
if command? :ronn
|
|
62
|
+
desc "Show the manual"
|
|
63
|
+
task :man => "man:build" do
|
|
64
|
+
exec "man man/mustache.1"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
desc "Build the manual"
|
|
68
|
+
task "man:build" do
|
|
69
|
+
sh "ronn -br5 --organization=SCHACON --manual='Rugged Manual' man/*.ron"
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
#
|
|
75
|
+
# Gems
|
|
76
|
+
#
|
|
77
|
+
|
|
78
|
+
begin
|
|
79
|
+
require 'mg'
|
|
80
|
+
MG.new("rugged.gemspec")
|
|
81
|
+
|
|
82
|
+
desc "Push a new version to Gemcutter and publish docs."
|
|
83
|
+
task :publish => "gem:publish" do
|
|
84
|
+
require File.dirname(__FILE__) + '/lib/mustache/version'
|
|
85
|
+
|
|
86
|
+
system "git tag v#{Rugged::Version}"
|
|
87
|
+
sh "git push origin master --tags"
|
|
88
|
+
sh "git clean -fd"
|
|
89
|
+
exec "rake pages"
|
|
90
|
+
end
|
|
91
|
+
rescue LoadError
|
|
92
|
+
warn "mg not available."
|
|
93
|
+
warn "Install it with: gem i mg"
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
#
|
|
97
|
+
# Documentation
|
|
98
|
+
#
|
|
99
|
+
|
|
100
|
+
desc "Publish to GitHub Pages"
|
|
101
|
+
task :pages => [ "man:build" ] do
|
|
102
|
+
Dir['man/*.html'].each do |f|
|
|
103
|
+
cp f, File.basename(f).sub('.html', '.newhtml')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
`git commit -am 'generated manual'`
|
|
107
|
+
`git checkout site`
|
|
108
|
+
|
|
109
|
+
Dir['*.newhtml'].each do |f|
|
|
110
|
+
mv f, f.sub('.newhtml', '.html')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
`git add .`
|
|
114
|
+
`git commit -m updated`
|
|
115
|
+
`git push site site:master`
|
|
116
|
+
`git checkout master`
|
|
117
|
+
puts :done
|
|
118
|
+
end
|
data/lib/rugged/index.rb
ADDED
|
Binary file
|
|
Binary file
|
data/lib/rugged/tree.rb
ADDED
data/lib/rugged.rb
ADDED
data/test/commit_test.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
|
2
|
+
|
|
3
|
+
context "Rugged::Commit tests" do
|
|
4
|
+
setup do
|
|
5
|
+
path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
|
|
6
|
+
@repo = Rugged::Repository.new(path)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test "can read the commit data" do
|
|
10
|
+
sha = "8496071c1b46c854b31185ea97743be6a8774479"
|
|
11
|
+
obj = @repo.lookup(sha)
|
|
12
|
+
|
|
13
|
+
assert_equal obj.sha, sha
|
|
14
|
+
assert_equal obj.type, "commit"
|
|
15
|
+
assert_equal obj.message, "testing\n"
|
|
16
|
+
assert_equal obj.message_short, "testing"
|
|
17
|
+
assert_equal obj.time.to_i, 1273360386
|
|
18
|
+
c = obj.committer
|
|
19
|
+
assert_equal c['name'], "Scott Chacon"
|
|
20
|
+
assert_equal c['time'].to_i, 1273360386
|
|
21
|
+
assert_equal c['email'], "schacon@gmail.com"
|
|
22
|
+
c = obj.author
|
|
23
|
+
assert_equal c['name'], "Scott Chacon"
|
|
24
|
+
assert_equal c['time'].to_i, 1273360386
|
|
25
|
+
assert_equal c['email'], "schacon@gmail.com"
|
|
26
|
+
assert_equal obj.tree.sha, "181037049a54a1eb5fab404658a3a250b44335d7"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
test "can write the commit data" do
|
|
30
|
+
sha = "8496071c1b46c854b31185ea97743be6a8774479"
|
|
31
|
+
obj = @repo.lookup(sha)
|
|
32
|
+
obj.message = 'new message'
|
|
33
|
+
obj.write
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ref: refs/heads/master
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Unnamed repository; edit this file 'description' to name the repository.
|
|
Binary file
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
0000000000000000000000000000000000000000 8496071c1b46c854b31185ea97743be6a8774479 Scott Chacon <schacon@gmail.com> 1273360386 -0700 commit (initial): testing
|
|
2
|
+
8496071c1b46c854b31185ea97743be6a8774479 5b5b025afb0b4c913b4c338a42934a3863bf3644 Scott Chacon <schacon@gmail.com> 1273610322 -0700 commit: another commit
|
|
3
|
+
5b5b025afb0b4c913b4c338a42934a3863bf3644 36060c58702ed4c2a40832c51758d5344201d89a Scott Chacon <schacon@gmail.com> 1288115062 -0200 push
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
0000000000000000000000000000000000000000 8496071c1b46c854b31185ea97743be6a8774479 Scott Chacon <schacon@gmail.com> 1273360386 -0700 commit (initial): testing
|
|
2
|
+
8496071c1b46c854b31185ea97743be6a8774479 5b5b025afb0b4c913b4c338a42934a3863bf3644 Scott Chacon <schacon@gmail.com> 1273610322 -0700 commit: another commit
|
|
3
|
+
5b5b025afb0b4c913b4c338a42934a3863bf3644 36060c58702ed4c2a40832c51758d5344201d89a Scott Chacon <schacon@gmail.com> 1288115062 -0200 push
|
data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.idx
ADDED
|
Binary file
|
data/test/fixtures/testrepo.git/objects/pack/pack-d7c6adf9f61318f041845b01440d09aa7a91e1b5.pack
ADDED
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
36060c58702ed4c2a40832c51758d5344201d89a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
5b5b025afb0b4c913b4c338a42934a3863bf3644
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0c37a5391bbff43c37f0d0371823a5509eed5b1d
|