rugged 0.0.1 → 0.1.0
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/README.md +11 -11
- data/Rakefile +10 -12
- data/lib/rugged.rb +1 -0
- data/lib/rugged/index.rb +1 -1
- data/lib/rugged/person.rb +20 -0
- data/lib/rugged/rugged.bundle +0 -0
- data/lib/rugged/tree.rb +1 -1
- data/lib/rugged/tree_entry.rb +1 -1
- data/lib/rugged/version.rb +2 -2
- data/test/blob_test.rb +32 -0
- data/test/commit_test.rb +24 -7
- data/test/fixtures/testrepo.git/objects/36/9b00a7700cca3a506d79e301d6ad8bf735d9ee +3 -0
- data/test/index_test.rb +3 -3
- data/test/lib_test.rb +6 -6
- data/test/object_test.rb +1 -1
- data/test/repo_pack_test.rb +1 -1
- data/test/repo_test.rb +1 -1
- data/test/tag_test.rb +10 -10
- data/test/tree_test.rb +1 -1
- data/test/walker_test.rb +1 -1
- metadata +7 -5
- data/lib/rugged/ribbit.bundle +0 -0
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Next, you need to install rake-compiler:
|
|
20
20
|
|
21
21
|
Now that those are installed, you can install Rugged:
|
22
22
|
|
23
|
-
$ git clone git://github.com/libgit2/
|
23
|
+
$ git clone git://github.com/libgit2/rugged.git
|
24
24
|
$ cd rugged
|
25
25
|
$ rake compile
|
26
26
|
$ rake test
|
@@ -48,19 +48,17 @@ Repository is the main repository object that everything
|
|
48
48
|
else will emanate from.
|
49
49
|
|
50
50
|
repo =
|
51
|
-
Rugged::Repository.new(path
|
51
|
+
Rugged::Repository.new(path)
|
52
52
|
ctnt, type = repo.read(sha)
|
53
53
|
gobj = repo.lookup(sha, type[?]) # optional type argument for checking
|
54
54
|
sha = repo.write(content, type)
|
55
55
|
sha = repo.hash(content, type)
|
56
56
|
bool = repo.exists(sha)
|
57
|
+
index = repo.index
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
59
|
+
The 'path' argument must point to an actual git repository folder. The library
|
60
|
+
will automatically guess if it's a bare repository or a '.git' folder inside a
|
61
|
+
working repository, and locate the working path accordingly.
|
64
62
|
|
65
63
|
Object Access
|
66
64
|
-----------------
|
@@ -146,11 +144,13 @@ anything beneath them (useful for a `git log master ^origin/master` type deal).
|
|
146
144
|
Index/Staging Area
|
147
145
|
-------------------
|
148
146
|
|
149
|
-
We can inspect and manipulate the Git Index as well.
|
147
|
+
We can inspect and manipulate the Git Index as well. To work with the index inside
|
148
|
+
of an existing repository, instantiate it by using the `Repository.index` method instead
|
149
|
+
of manually opening the Index by its path.
|
150
150
|
|
151
|
-
# the remove and add functions immediately flush to the index file on disk
|
151
|
+
# TODO: the remove and add functions immediately flush to the index file on disk
|
152
152
|
index =
|
153
|
-
Rugged::Index.new(
|
153
|
+
Rugged::Index.new(path)
|
154
154
|
index.refresh # re-read the index file from disk
|
155
155
|
int = index.entry_count # count of index entries
|
156
156
|
ent = index.get_entry(i/path)
|
data/Rakefile
CHANGED
@@ -22,18 +22,16 @@ end
|
|
22
22
|
|
23
23
|
task :default => :test
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
t.verbose = false
|
36
|
-
end
|
25
|
+
desc "Run tests"
|
26
|
+
task :turn do
|
27
|
+
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
|
28
|
+
sh "turn test/*_test.rb #{suffix}"
|
29
|
+
end
|
30
|
+
|
31
|
+
Rake::TestTask.new do |t|
|
32
|
+
t.libs << 'lib'
|
33
|
+
t.pattern = 'test/**/*_test.rb'
|
34
|
+
t.verbose = false
|
37
35
|
end
|
38
36
|
|
39
37
|
if command? :kicker
|
data/lib/rugged.rb
CHANGED
data/lib/rugged/index.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Rugged
|
2
|
+
class Person
|
3
|
+
attr_accessor :name, :email
|
4
|
+
|
5
|
+
def initialize(name, email, time)
|
6
|
+
@name = name
|
7
|
+
@email = email
|
8
|
+
@time = time.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def time
|
12
|
+
Time.at(@time)
|
13
|
+
end
|
14
|
+
|
15
|
+
def time=(t)
|
16
|
+
@time = t.to_i
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/lib/rugged/rugged.bundle
CHANGED
Binary file
|
data/lib/rugged/tree.rb
CHANGED
data/lib/rugged/tree_entry.rb
CHANGED
data/lib/rugged/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
Version = VERSION = '0.0
|
1
|
+
module Rugged
|
2
|
+
Version = VERSION = '0.1.0'
|
3
3
|
end
|
data/test/blob_test.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path "../test_helper", __FILE__
|
2
|
+
|
3
|
+
context "Rugged::Blob tests" do
|
4
|
+
setup do
|
5
|
+
@path = File.dirname(__FILE__) + '/fixtures/testrepo.git/'
|
6
|
+
@repo = Rugged::Repository.new(@path)
|
7
|
+
@sha = "fa49b077972391ad58037050f2a75f74e3671e92"
|
8
|
+
end
|
9
|
+
|
10
|
+
test "can read the blob data" do
|
11
|
+
blob = @repo.lookup(@sha)
|
12
|
+
assert_equal 9, blob.size
|
13
|
+
assert_equal "new file\n", blob.content
|
14
|
+
assert_equal "blob", blob.type
|
15
|
+
assert_equal @sha, blob.sha
|
16
|
+
end
|
17
|
+
|
18
|
+
test "can rewrite blob data" do
|
19
|
+
blob = @repo.lookup(@sha)
|
20
|
+
blob.content = "my new content"
|
21
|
+
assert_equal @sha, blob.sha
|
22
|
+
blob.write # should change the sha
|
23
|
+
assert_equal "2dd916ea1ff086d61fbc1c286079305ffad4e92e", blob.sha
|
24
|
+
FileUtils.rm File.join(@path, "objects/2d/d916ea1ff086d61fbc1c286079305ffad4e92e")
|
25
|
+
end
|
26
|
+
|
27
|
+
test "can write new blob data" do
|
28
|
+
blob = Rugged::Blob.new(@repo)
|
29
|
+
blob.content = "a new blob content"
|
30
|
+
blob.write
|
31
|
+
end
|
32
|
+
end
|
data/test/commit_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path "../test_helper", __FILE__
|
2
2
|
|
3
3
|
context "Rugged::Commit tests" do
|
4
4
|
setup do
|
@@ -16,13 +16,13 @@ context "Rugged::Commit tests" do
|
|
16
16
|
assert_equal obj.message_short, "testing"
|
17
17
|
assert_equal obj.time.to_i, 1273360386
|
18
18
|
c = obj.committer
|
19
|
-
assert_equal c
|
20
|
-
assert_equal c
|
21
|
-
assert_equal c
|
19
|
+
assert_equal c.name, "Scott Chacon"
|
20
|
+
assert_equal c.time.to_i, 1273360386
|
21
|
+
assert_equal c.email, "schacon@gmail.com"
|
22
22
|
c = obj.author
|
23
|
-
assert_equal c
|
24
|
-
assert_equal c
|
25
|
-
assert_equal c
|
23
|
+
assert_equal c.name, "Scott Chacon"
|
24
|
+
assert_equal c.time.to_i, 1273360386
|
25
|
+
assert_equal c.email, "schacon@gmail.com"
|
26
26
|
assert_equal obj.tree.sha, "181037049a54a1eb5fab404658a3a250b44335d7"
|
27
27
|
end
|
28
28
|
|
@@ -33,4 +33,21 @@ context "Rugged::Commit tests" do
|
|
33
33
|
obj.write
|
34
34
|
end
|
35
35
|
|
36
|
+
test "can write new commit data" do
|
37
|
+
tsha = "c4dc1555e4d4fa0e0c9c3fc46734c7c35b3ce90b"
|
38
|
+
tree = @repo.lookup(tsha)
|
39
|
+
|
40
|
+
obj = Rugged::Commit.new(@repo)
|
41
|
+
person = Rugged::Person.new('Scott', 'schacon@gmail.com', Time.now)
|
42
|
+
|
43
|
+
obj.message = 'new message'
|
44
|
+
obj.author = person
|
45
|
+
obj.committer = person
|
46
|
+
obj.tree = tree
|
47
|
+
obj.write
|
48
|
+
|
49
|
+
pp obj
|
50
|
+
pp obj.sha
|
51
|
+
end
|
52
|
+
|
36
53
|
end
|
data/test/index_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path "../test_helper", __FILE__
|
2
2
|
require 'base64'
|
3
3
|
require 'tempfile'
|
4
4
|
require 'fileutils'
|
@@ -81,8 +81,8 @@ context "Rugged::Index reading stuff" do
|
|
81
81
|
|
82
82
|
assert_equal 'new_path', e.path
|
83
83
|
assert_equal '12ea3153a78002a988bb92f4123e7e831fd1138a', e.sha
|
84
|
-
assert_equal now, e.mtime
|
85
|
-
assert_equal now, e.ctime
|
84
|
+
assert_equal now.to_i, e.mtime.to_i
|
85
|
+
assert_equal now.to_i, e.ctime.to_i
|
86
86
|
assert_equal 1000, e.file_size
|
87
87
|
assert_equal 234881027, e.dev
|
88
88
|
assert_equal 88888, e.ino
|
data/test/lib_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path "../test_helper", __FILE__
|
2
2
|
require 'base64'
|
3
3
|
|
4
4
|
context "Rugged::Lib stuff" do
|
@@ -6,27 +6,27 @@ context "Rugged::Lib stuff" do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
test "can convert hex into raw sha" do
|
9
|
-
raw = Rugged::
|
9
|
+
raw = Rugged::hex_to_raw("ce08fe4884650f067bd5703b6a59a8b3b3c99a09")
|
10
10
|
b64raw = Base64.encode64(raw).strip
|
11
11
|
assert_equal "zgj+SIRlDwZ71XA7almos7PJmgk=", b64raw
|
12
12
|
end
|
13
13
|
|
14
14
|
test "converts hex into raw sha correctly" do
|
15
15
|
hex = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09"
|
16
|
-
raw1 = Rugged::
|
16
|
+
raw1 = Rugged::hex_to_raw(hex)
|
17
17
|
raw2 = [hex].pack("H*")
|
18
18
|
assert_equal raw1, raw2
|
19
19
|
end
|
20
20
|
|
21
21
|
test "can convert raw sha into hex" do
|
22
22
|
raw = Base64.decode64("FqASNFZ4mrze9Ld1ITwjqL109eA=")
|
23
|
-
hex = Rugged::
|
23
|
+
hex = Rugged::raw_to_hex(raw)
|
24
24
|
assert_equal "16a0123456789abcdef4b775213c23a8bd74f5e0", hex
|
25
25
|
end
|
26
26
|
|
27
27
|
test "converts raw into hex sha correctly" do
|
28
|
-
raw = Rugged::
|
29
|
-
hex1 = Rugged::
|
28
|
+
raw = Rugged::hex_to_raw("ce08fe4884650f067bd5703b6a59a8b3b3c99a09")
|
29
|
+
hex1 = Rugged::raw_to_hex(raw)
|
30
30
|
hex2 = raw.unpack("H*")[0]
|
31
31
|
assert_equal hex1, hex2
|
32
32
|
end
|
data/test/object_test.rb
CHANGED
data/test/repo_pack_test.rb
CHANGED
data/test/repo_test.rb
CHANGED
data/test/tag_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.
|
1
|
+
require File.expand_path "../test_helper", __FILE__
|
2
2
|
|
3
3
|
context "Rugged::Tag tests" do
|
4
4
|
setup do
|
@@ -11,15 +11,15 @@ context "Rugged::Tag tests" do
|
|
11
11
|
obj = @repo.lookup(sha)
|
12
12
|
|
13
13
|
assert_equal sha, obj.sha
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
assert_equal 1288114383, c
|
22
|
-
assert_equal "schacon@gmail.com", c
|
14
|
+
assert_equal "tag", obj.type
|
15
|
+
assert_equal "test tag message\n", obj.message
|
16
|
+
assert_equal "v1.0", obj.name
|
17
|
+
assert_equal "5b5b025afb0b4c913b4c338a42934a3863bf3644", obj.target.sha
|
18
|
+
assert_equal "commit", obj.target_type
|
19
|
+
c = obj.tagger
|
20
|
+
assert_equal "Scott Chacon", c.name
|
21
|
+
assert_equal 1288114383, c.time.to_i
|
22
|
+
assert_equal "schacon@gmail.com", c.email
|
23
23
|
end
|
24
24
|
|
25
25
|
test "can write the tag data" do
|
data/test/tree_test.rb
CHANGED
data/test/walker_test.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rugged
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Scott Chacon
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-23 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -36,12 +36,13 @@ files:
|
|
36
36
|
- Rakefile
|
37
37
|
- LICENSE
|
38
38
|
- lib/rugged/index.rb
|
39
|
-
- lib/rugged/
|
39
|
+
- lib/rugged/person.rb
|
40
40
|
- lib/rugged/rugged.bundle
|
41
41
|
- lib/rugged/tree.rb
|
42
42
|
- lib/rugged/tree_entry.rb
|
43
43
|
- lib/rugged/version.rb
|
44
44
|
- lib/rugged.rb
|
45
|
+
- test/blob_test.rb
|
45
46
|
- test/commit_test.rb
|
46
47
|
- test/fixtures/testrepo.git/config
|
47
48
|
- test/fixtures/testrepo.git/description
|
@@ -56,6 +57,7 @@ files:
|
|
56
57
|
- test/fixtures/testrepo.git/objects/18/10dff58d8a660512d4832e740f692884338ccd
|
57
58
|
- test/fixtures/testrepo.git/objects/2d/2eff63372b08adf0a9eb84109ccf7d19e2f3a2
|
58
59
|
- test/fixtures/testrepo.git/objects/36/060c58702ed4c2a40832c51758d5344201d89a
|
60
|
+
- test/fixtures/testrepo.git/objects/36/9b00a7700cca3a506d79e301d6ad8bf735d9ee
|
59
61
|
- test/fixtures/testrepo.git/objects/45/b983be36b73c0788dc9cbcb76cbb80fc7bb057
|
60
62
|
- test/fixtures/testrepo.git/objects/4a/202b346bb0fb0db7eff3cffeb3c70babbd2045
|
61
63
|
- test/fixtures/testrepo.git/objects/5b/5b025afb0b4c913b4c338a42934a3863bf3644
|
data/lib/rugged/ribbit.bundle
DELETED
Binary file
|