rugged 0.1.2 → 0.16.0b1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +25 -36
- data/Rakefile +20 -98
- data/ext/rugged/extconf.rb +44 -4
- data/ext/rugged/remote.c +215 -0
- data/ext/rugged/rugged.c +171 -0
- data/ext/rugged/rugged.h +126 -0
- data/ext/rugged/rugged_blob.c +99 -0
- data/ext/rugged/rugged_commit.c +224 -0
- data/ext/rugged/rugged_config.c +238 -0
- data/ext/rugged/rugged_index.c +440 -0
- data/ext/rugged/rugged_object.c +203 -0
- data/ext/rugged/rugged_reference.c +401 -0
- data/ext/rugged/rugged_repo.c +482 -0
- data/ext/rugged/rugged_revwalk.c +138 -0
- data/ext/rugged/rugged_signature.c +80 -0
- data/ext/rugged/rugged_tag.c +216 -0
- data/ext/rugged/rugged_tree.c +322 -0
- data/ext/rugged/vendor/libgit2-dist.tar.gz +0 -0
- data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.c +1778 -0
- data/ext/rugged/vendor/libgit2-dist/deps/http-parser/http_parser.h +267 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/adler32.c +169 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.c +442 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/crc32.h +441 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.c +1834 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/deflate.h +342 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.c +340 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffast.h +11 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inffixed.h +94 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.c +1480 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inflate.h +122 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.c +330 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/inftrees.h +62 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.c +1244 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/trees.h +128 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zconf.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zlib.h +1613 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.c +318 -0
- data/ext/rugged/vendor/libgit2-dist/deps/zlib/zutil.h +274 -0
- data/ext/rugged/vendor/libgit2-dist/examples/general.c +451 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/common.h +14 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/fetch.c +97 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/git2.c +58 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/index-pack.c +47 -0
- data/ext/rugged/vendor/libgit2-dist/examples/network/ls-remote.c +76 -0
- data/ext/rugged/vendor/libgit2-dist/examples/showindex.c +43 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2.h +44 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/blob.h +120 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/branch.h +15 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/commit.h +263 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/common.h +103 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/config.h +278 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/errors.h +144 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/index.h +306 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/indexer.h +76 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/inttypes.h +305 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/net.h +51 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/object.h +173 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb.h +331 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/odb_backend.h +100 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/oid.h +218 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/reflog.h +128 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/refs.h +309 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/refspec.h +60 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/remote.h +176 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/repository.h +290 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/revwalk.h +169 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/signature.h +65 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/status.h +63 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/stdint.h +247 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tag.h +279 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/threads.h +48 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/tree.h +318 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/types.h +169 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/version.h +15 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/windows.h +59 -0
- data/ext/rugged/vendor/libgit2-dist/include/git2/zlib.h +40 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.c +135 -0
- data/ext/rugged/vendor/libgit2-dist/src/blob.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/bswap.h +97 -0
- data/ext/rugged/vendor/libgit2-dist/src/buffer.c +113 -0
- data/ext/rugged/vendor/libgit2-dist/src/buffer.h +32 -0
- data/ext/rugged/vendor/libgit2-dist/src/cache.c +111 -0
- data/ext/rugged/vendor/libgit2-dist/src/cache.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/cc-compat.h +67 -0
- data/ext/rugged/vendor/libgit2-dist/src/commit.c +299 -0
- data/ext/rugged/vendor/libgit2-dist/src/commit.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/common.h +64 -0
- data/ext/rugged/vendor/libgit2-dist/src/config.c +418 -0
- data/ext/rugged/vendor/libgit2-dist/src/config.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/config_file.c +1210 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/src/delta-apply.h +33 -0
- data/ext/rugged/vendor/libgit2-dist/src/dir.h +47 -0
- data/ext/rugged/vendor/libgit2-dist/src/errors.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/src/fetch.c +172 -0
- data/ext/rugged/vendor/libgit2-dist/src/fetch.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.c +400 -0
- data/ext/rugged/vendor/libgit2-dist/src/filebuf.h +72 -0
- data/ext/rugged/vendor/libgit2-dist/src/fileops.c +358 -0
- data/ext/rugged/vendor/libgit2-dist/src/fileops.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.c +134 -0
- data/ext/rugged/vendor/libgit2-dist/src/global.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/hash.c +74 -0
- data/ext/rugged/vendor/libgit2-dist/src/hash.h +29 -0
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.c +243 -0
- data/ext/rugged/vendor/libgit2-dist/src/hashtable.h +80 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.c +918 -0
- data/ext/rugged/vendor/libgit2-dist/src/index.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/indexer.c +401 -0
- data/ext/rugged/vendor/libgit2-dist/src/map.h +37 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.c +272 -0
- data/ext/rugged/vendor/libgit2-dist/src/mwindow.h +45 -0
- data/ext/rugged/vendor/libgit2-dist/src/netops.c +198 -0
- data/ext/rugged/vendor/libgit2-dist/src/netops.h +36 -0
- data/ext/rugged/vendor/libgit2-dist/src/object.c +295 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb.c +672 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb.h +43 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb_loose.c +855 -0
- data/ext/rugged/vendor/libgit2-dist/src/odb_pack.c +485 -0
- data/ext/rugged/vendor/libgit2-dist/src/oid.c +388 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.c +788 -0
- data/ext/rugged/vendor/libgit2-dist/src/pack.h +99 -0
- data/ext/rugged/vendor/libgit2-dist/src/path.c +270 -0
- data/ext/rugged/vendor/libgit2-dist/src/path.h +84 -0
- data/ext/rugged/vendor/libgit2-dist/src/pkt.c +426 -0
- data/ext/rugged/vendor/libgit2-dist/src/pkt.h +77 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/src/posix.h +69 -0
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.c +70 -0
- data/ext/rugged/vendor/libgit2-dist/src/ppc/sha1.h +26 -0
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.c +141 -0
- data/ext/rugged/vendor/libgit2-dist/src/pqueue.h +81 -0
- data/ext/rugged/vendor/libgit2-dist/src/protocol.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/src/protocol.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/reflog.c +318 -0
- data/ext/rugged/vendor/libgit2-dist/src/reflog.h +34 -0
- data/ext/rugged/vendor/libgit2-dist/src/refs.c +1693 -0
- data/ext/rugged/vendor/libgit2-dist/src/refs.h +58 -0
- data/ext/rugged/vendor/libgit2-dist/src/refspec.c +95 -0
- data/ext/rugged/vendor/libgit2-dist/src/refspec.h +23 -0
- data/ext/rugged/vendor/libgit2-dist/src/remote.c +339 -0
- data/ext/rugged/vendor/libgit2-dist/src/remote.h +25 -0
- data/ext/rugged/vendor/libgit2-dist/src/repository.c +849 -0
- data/ext/rugged/vendor/libgit2-dist/src/repository.h +60 -0
- data/ext/rugged/vendor/libgit2-dist/src/revwalk.c +569 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1.c +280 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1.h +21 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.c +177 -0
- data/ext/rugged/vendor/libgit2-dist/src/sha1_lookup.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/signature.c +335 -0
- data/ext/rugged/vendor/libgit2-dist/src/signature.h +18 -0
- data/ext/rugged/vendor/libgit2-dist/src/status.c +696 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.c +446 -0
- data/ext/rugged/vendor/libgit2-dist/src/tag.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.c +55 -0
- data/ext/rugged/vendor/libgit2-dist/src/thread-utils.h +108 -0
- data/ext/rugged/vendor/libgit2-dist/src/transport.c +85 -0
- data/ext/rugged/vendor/libgit2-dist/src/transport.h +110 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/git.c +502 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/http.c +756 -0
- data/ext/rugged/vendor/libgit2-dist/src/transports/local.c +235 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.c +201 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree-cache.h +31 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree.c +758 -0
- data/ext/rugged/vendor/libgit2-dist/src/tree.h +37 -0
- data/ext/rugged/vendor/libgit2-dist/src/tsort.c +365 -0
- data/ext/rugged/vendor/libgit2-dist/src/unix/map.c +70 -0
- data/ext/rugged/vendor/libgit2-dist/src/unix/posix.h +25 -0
- data/ext/rugged/vendor/libgit2-dist/src/util.c +381 -0
- data/ext/rugged/vendor/libgit2-dist/src/util.h +137 -0
- data/ext/rugged/vendor/libgit2-dist/src/vector.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/src/vector.h +45 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/dir.c +115 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.c +180 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/fnmatch.h +27 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/map.c +131 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/mingw-compat.h +24 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/msvc-compat.h +38 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix.h +53 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/posix_w32.c +404 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.c +65 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/pthread.h +40 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.c +88 -0
- data/ext/rugged/vendor/libgit2-dist/src/win32/utf-conv.h +17 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/buf/basic.c +29 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay.h +187 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_libgit2.h +28 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/clay_main.c +1073 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/add.c +37 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/new.c +36 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/read.c +209 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/stress.c +39 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/config/write.c +77 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/dirent.c +222 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/filebuf.c +106 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/oid.c +18 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/path.c +139 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/rmdir.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/string.c +28 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/strtol.c +37 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/core/vector.c +66 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/index/rename.c +60 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/network/remotes.c +50 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/chars.c +52 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/compare.c +124 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/convert.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/data.h +323 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/fromstr.c +30 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/hash.c +162 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/short.c +94 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/size.c +13 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/raw/type2string.c +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/object/tree/frompath.c +75 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose.c +84 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/loose_data.h +522 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/pack_data.h +151 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/packed.c +78 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/odb/sorting.c +71 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/getters.c +68 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/init.c +104 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/repo/open.c +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/single.c +38 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/status_data.h +48 -0
- data/ext/rugged/vendor/libgit2-dist/tests-clay/status/worktree.c +124 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t00-core.c +628 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t01-data.h +322 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t01-rawobj.c +638 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t03-data.h +344 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t03-objwrite.c +255 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t04-commit.c +788 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t05-revwalk.c +140 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t06-index.c +219 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t07-hashtable.c +192 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t08-tag.c +357 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t09-tree.c +221 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t10-refs.c +1294 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t12-repo.c +174 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t13-threads.c +41 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t17-bufs.c +61 -0
- data/ext/rugged/vendor/libgit2-dist/tests/t18-status.c +448 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.c +310 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_helpers.h +83 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.c +198 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_lib.h +54 -0
- data/ext/rugged/vendor/libgit2-dist/tests/test_main.c +89 -0
- data/lib/rugged.rb +4 -3
- data/lib/rugged/index.rb +0 -8
- data/lib/rugged/objects.rb +45 -0
- data/lib/rugged/repository.rb +29 -0
- data/lib/rugged/tree.rb +16 -6
- data/lib/rugged/version.rb +1 -1
- data/lib/rugged/walker.rb +5 -0
- data/test/blob_test.rb +18 -14
- data/test/commit_test.rb +28 -26
- data/test/coverage/HEAD.json +1 -0
- data/test/coverage/cover.rb +106 -0
- data/test/fixtures/testrepo.git/refs/heads/new_name +1 -0
- data/test/index_test.rb +101 -78
- data/test/lib_test.rb +4 -4
- data/test/object_test.rb +3 -3
- data/test/reference_test.rb +75 -0
- data/test/remote_test.rb +19 -0
- data/test/repo_pack_test.rb +4 -4
- data/test/repo_test.rb +44 -15
- data/test/tag_test.rb +7 -17
- data/test/test_helper.rb +24 -5
- data/test/tree_test.rb +30 -12
- data/test/walker_test.rb +40 -31
- metadata +273 -50
- data/lib/rugged/person.rb +0 -20
- data/lib/rugged/tree_entry.rb +0 -9
- data/test/fixtures/testrepo.git/objects/1d/83f106355e4309a293e42ad2a2c4b8bdbe77ae +0 -0
- data/test/fixtures/testrepo.git/objects/2f/3321418db5b2a841375b8b70880a8ab5a4148f +0 -0
- data/test/fixtures/testrepo.git/objects/36/9b00a7700cca3a506d79e301d6ad8bf735d9ee +0 -3
- data/test/fixtures/testrepo.git/objects/3d/b1b5ceace59ff65279757003763046fd4cbbe6 +0 -0
- data/test/fixtures/testrepo.git/objects/4c/d1604907792e2c43e03dcec1216f99d63e68c4 +0 -3
- data/test/fixtures/testrepo.git/objects/e0/f46d77041c149296549b01ed4a18b02c4b7400 +0 -0
data/README.md
CHANGED
@@ -11,6 +11,8 @@ First you need to install libgit2:
|
|
11
11
|
|
12
12
|
$ git clone git://github.com/libgit2/libgit2.git
|
13
13
|
$ cd libgit2
|
14
|
+
$ mdkir build && cd build
|
15
|
+
$ cmake ..
|
14
16
|
$ make
|
15
17
|
$ make install
|
16
18
|
|
@@ -32,8 +34,8 @@ API
|
|
32
34
|
There is a general library for some basic Gitty methods. So far, just converting
|
33
35
|
a raw sha (20 bytes) into a readable hex sha (40 char).
|
34
36
|
|
35
|
-
raw = Rugged
|
36
|
-
hex = Rugged
|
37
|
+
raw = Rugged.hex_to_raw(hex_sha)
|
38
|
+
hex = Rugged.raw_to_hex(20_byte_raw_sha)
|
37
39
|
|
38
40
|
|
39
41
|
Repository Access
|
@@ -74,22 +76,20 @@ but all of these methods should be useful in it's derived classes
|
|
74
76
|
# the repository and instantiated
|
75
77
|
# If the 'sha' ID of the object is missing, the object will be
|
76
78
|
# created in memory and can be written later on to the repository
|
77
|
-
Rugged::Object(repo, sha)
|
78
|
-
obj.
|
79
|
+
Rugged::Object.new(repo, sha)
|
80
|
+
obj.oid
|
79
81
|
obj.type
|
80
82
|
|
81
83
|
str = obj.read_raw # read the raw data of the object
|
82
|
-
sha = obj.write # write the object to a repository
|
83
|
-
|
84
84
|
|
85
85
|
The next classes are for consuming and creating the 4 base
|
86
|
-
git object types.
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
git object types. Just about every method should be able to take
|
87
|
+
a parameter to change the value so the object can be re-written
|
88
|
+
slightly different or no parameter to simply read the current
|
89
|
+
value out.
|
90
90
|
|
91
|
-
gobjc =
|
92
|
-
Rugged::Commit.new < Rugged::Object
|
91
|
+
gobjc = Rugged::Commit.new
|
92
|
+
# Rugged::Commit.new < Rugged::Object
|
93
93
|
str = gobjc.message
|
94
94
|
str = gobjc.message_short
|
95
95
|
str = gobjc.message_body # TODO
|
@@ -97,18 +97,18 @@ to simply read the current value out
|
|
97
97
|
prsn = gobjc.committer
|
98
98
|
gobjr = gobjc.tree
|
99
99
|
sha = gobjc.tree_sha
|
100
|
-
arr = gobjc.parents [*] # TODO
|
100
|
+
arr = gobjc.parents [*] # TODO: write
|
101
101
|
|
102
|
-
gobtg =
|
103
|
-
Rugged::Tag.new < Rugged::Object
|
102
|
+
gobtg = Rugged::Tag.new
|
103
|
+
# Rugged::Tag.new < Rugged::Object
|
104
104
|
gobj = gobtg.target
|
105
105
|
int = gobtg.target_type
|
106
106
|
str = gobtg.name
|
107
107
|
prsn = gobtg.tagger
|
108
108
|
str = gobtg.message
|
109
109
|
|
110
|
-
gobtr =
|
111
|
-
Rugged::Tree.new < Rugged::Object
|
110
|
+
gobtr = Rugged::Tree.new
|
111
|
+
# Rugged::Tree.new < Rugged::Object
|
112
112
|
gobtr.add(ent) # TODO
|
113
113
|
gobtr.remove(name) # TODO
|
114
114
|
int = gobtr.entry_count
|
@@ -133,10 +133,11 @@ objects, one at a time. You can also hide() commits if you are not interested in
|
|
133
133
|
anything beneath them (useful for a `git log master ^origin/master` type deal).
|
134
134
|
|
135
135
|
walker =
|
136
|
-
Rugged::Walker.new(repo)
|
136
|
+
Rugged::Walker.new(repo)
|
137
|
+
walker.walk { |c| puts c.inspect } # walk is just an alias of each
|
138
|
+
walker.each { |c| puts c.inspect }
|
137
139
|
walker.push(hex_sha_interesting)
|
138
140
|
walker.hide(hex_sha_uninteresting)
|
139
|
-
cmt = walker.next # false if none left
|
140
141
|
walker.reset
|
141
142
|
|
142
143
|
|
@@ -151,29 +152,17 @@ of manually opening the Index by its path.
|
|
151
152
|
# TODO: the remove and add functions immediately flush to the index file on disk
|
152
153
|
index =
|
153
154
|
Rugged::Index.new(path)
|
154
|
-
index.
|
155
|
-
int = index.
|
155
|
+
index.reload # re-read the index file from disk
|
156
|
+
int = index.count # count of index entries
|
157
|
+
index.entries # collection of index entries
|
158
|
+
index.each { |i| puts i.inspect }
|
156
159
|
ent = index.get_entry(i/path)
|
157
160
|
index.remove(i/path)
|
158
161
|
index.add(ientry) # also updates existing entry if there is one
|
159
162
|
index.add(path) # create ientry from file in path, update index
|
160
163
|
#TODO index.read_tree(gobtr, path='/')
|
161
164
|
#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?)
|
165
|
+
|
177
166
|
|
178
167
|
Index Status # TODO
|
179
168
|
-------------------
|
data/Rakefile
CHANGED
@@ -1,31 +1,34 @@
|
|
1
|
-
# stolen largely from defunkt/mustache
|
2
1
|
require 'rake/testtask'
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
require 'rake/extensiontask'
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# Helpers
|
12
|
-
#
|
3
|
+
begin
|
4
|
+
require 'rake/extensiontask'
|
5
|
+
rescue LoadError
|
6
|
+
abort <<-error
|
7
|
+
rake-compile is missing; Rugged depends on rake-compiler to build the C wrapping code.
|
13
8
|
|
14
|
-
|
15
|
-
|
9
|
+
Install it by running `gem i rake-compiler`
|
10
|
+
error
|
16
11
|
end
|
17
12
|
|
13
|
+
Rake::ExtensionTask.new('rugged') do |r|
|
14
|
+
r.lib_dir = 'lib/rugged'
|
15
|
+
end
|
18
16
|
|
19
17
|
#
|
20
18
|
# Tests
|
21
19
|
#
|
20
|
+
task :default => [:compile, :test]
|
22
21
|
|
23
|
-
task :
|
22
|
+
task :pack_dist do
|
23
|
+
dir = File.dirname(File.expand_path(__FILE__))
|
24
|
+
output = File.join(dir, 'ext', 'rugged', 'vendor', 'libgit2-dist.tar.gz')
|
25
|
+
Dir.chdir(ENV['LIBGIT2_PATH']) do
|
26
|
+
`git archive --format=tar --prefix=libgit2-dist/ HEAD | gzip > #{output}`
|
27
|
+
end
|
28
|
+
end
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
suffix = "-n #{ENV['TEST']}" if ENV['TEST']
|
28
|
-
sh "turn test/*_test.rb #{suffix}"
|
30
|
+
task :cover do
|
31
|
+
ruby 'test/coverage/cover.rb'
|
29
32
|
end
|
30
33
|
|
31
34
|
Rake::TestTask.new do |t|
|
@@ -33,84 +36,3 @@ Rake::TestTask.new do |t|
|
|
33
36
|
t.pattern = 'test/**/*_test.rb'
|
34
37
|
t.verbose = false
|
35
38
|
end
|
36
|
-
|
37
|
-
if command? :kicker
|
38
|
-
desc "Launch Kicker (like autotest)"
|
39
|
-
task :kicker do
|
40
|
-
puts "Kicking... (ctrl+c to cancel)"
|
41
|
-
exec "kicker -e rake test lib"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
desc "Update the libgit2 SHA"
|
46
|
-
task :libgit do
|
47
|
-
sha = `git --git-dir=../libgit2/.git rev-parse HEAD`
|
48
|
-
File.open("LIBGIT2_VERSION", 'w') do |f|
|
49
|
-
f.puts "# git --git-dir=../libgit2/.git rev-parse HEAD"
|
50
|
-
f.puts sha
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
#
|
56
|
-
# Ron
|
57
|
-
#
|
58
|
-
|
59
|
-
if command? :ronn
|
60
|
-
desc "Show the manual"
|
61
|
-
task :man => "man:build" do
|
62
|
-
exec "man man/mustache.1"
|
63
|
-
end
|
64
|
-
|
65
|
-
desc "Build the manual"
|
66
|
-
task "man:build" do
|
67
|
-
sh "ronn -br5 --organization=SCHACON --manual='Rugged Manual' man/*.ron"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
#
|
73
|
-
# Gems
|
74
|
-
#
|
75
|
-
|
76
|
-
begin
|
77
|
-
require 'mg'
|
78
|
-
MG.new("rugged.gemspec")
|
79
|
-
|
80
|
-
desc "Push a new version to Gemcutter and publish docs."
|
81
|
-
task :publish => "gem:publish" do
|
82
|
-
require File.dirname(__FILE__) + '/lib/mustache/version'
|
83
|
-
|
84
|
-
system "git tag v#{Rugged::Version}"
|
85
|
-
sh "git push origin master --tags"
|
86
|
-
sh "git clean -fd"
|
87
|
-
exec "rake pages"
|
88
|
-
end
|
89
|
-
rescue LoadError
|
90
|
-
warn "mg not available."
|
91
|
-
warn "Install it with: gem i mg"
|
92
|
-
end
|
93
|
-
|
94
|
-
#
|
95
|
-
# Documentation
|
96
|
-
#
|
97
|
-
|
98
|
-
desc "Publish to GitHub Pages"
|
99
|
-
task :pages => [ "man:build" ] do
|
100
|
-
Dir['man/*.html'].each do |f|
|
101
|
-
cp f, File.basename(f).sub('.html', '.newhtml')
|
102
|
-
end
|
103
|
-
|
104
|
-
`git commit -am 'generated manual'`
|
105
|
-
`git checkout site`
|
106
|
-
|
107
|
-
Dir['*.newhtml'].each do |f|
|
108
|
-
mv f, f.sub('.newhtml', '.html')
|
109
|
-
end
|
110
|
-
|
111
|
-
`git add .`
|
112
|
-
`git commit -m updated`
|
113
|
-
`git push site site:master`
|
114
|
-
`git checkout master`
|
115
|
-
puts :done
|
116
|
-
end
|
data/ext/rugged/extconf.rb
CHANGED
@@ -1,9 +1,49 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
|
3
|
+
def sys(cmd)
|
4
|
+
puts " -- #{cmd}"
|
5
|
+
unless ret = xsystem(cmd)
|
6
|
+
raise "ERROR: '#{cmd}' failed"
|
7
|
+
end
|
8
|
+
ret
|
9
|
+
end
|
4
10
|
|
5
|
-
|
6
|
-
|
11
|
+
if `which make`.strip.empty?
|
12
|
+
STDERR.puts "ERROR: GNU make is required to build Rugged"
|
13
|
+
exit(1)
|
14
|
+
end
|
7
15
|
|
8
|
-
|
16
|
+
if p = ENV['LIBGIT2_PATH']
|
17
|
+
$INCFLAGS[0,0] = " -I#{File.join(p, 'include')} "
|
18
|
+
$LDFLAGS << " -L#{p} "
|
19
|
+
|
20
|
+
unless have_library 'git2' and have_header 'git2.h'
|
21
|
+
STDERR.puts "ERROR: Invalid `LIBGIT2_PATH` environment"
|
22
|
+
exit(1)
|
23
|
+
end
|
24
|
+
else
|
25
|
+
CWD = File.expand_path(File.dirname(__FILE__))
|
26
|
+
|
27
|
+
LIBGIT2_DIST = 'libgit2-dist.tar.gz'
|
28
|
+
LIBGIT2_DIR = File.basename(LIBGIT2_DIST, '.tar.gz')
|
29
|
+
|
30
|
+
Dir.chdir("#{CWD}/vendor") do
|
31
|
+
FileUtils.rm_rf(LIBGIT2_DIR) if File.exists?(LIBGIT2_DIR)
|
9
32
|
|
33
|
+
sys("tar zxvf #{LIBGIT2_DIST}")
|
34
|
+
Dir.chdir(LIBGIT2_DIR) do
|
35
|
+
sys("make -f Makefile.embed")
|
36
|
+
FileUtils.cp "libgit2.a", "#{CWD}/libgit2_embed.a"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
$INCFLAGS[0,0] = " -I#{CWD}/vendor/#{LIBGIT2_DIR}/include "
|
41
|
+
$LDFLAGS << " -L#{CWD} "
|
42
|
+
|
43
|
+
unless have_library 'git2_embed' and have_header 'git2.h'
|
44
|
+
STDERR.puts "ERROR: Failed to build libgit2"
|
45
|
+
exit(1)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
create_makefile("rugged/rugged")
|
data/ext/rugged/remote.c
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
/*
|
2
|
+
* The MIT License
|
3
|
+
*
|
4
|
+
* Copyright (c) 2011 GitHub, Inc
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
14
|
+
* all copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
* THE SOFTWARE.
|
23
|
+
*/
|
24
|
+
|
25
|
+
#include "rugged.h"
|
26
|
+
|
27
|
+
extern VALUE rb_mRugged;
|
28
|
+
extern VALUE rb_cRuggedRepo;
|
29
|
+
VALUE rb_cRuggedRemote;
|
30
|
+
|
31
|
+
static void rb_git_remote__free(git_remote *remote)
|
32
|
+
{
|
33
|
+
git_remote_free(remote);
|
34
|
+
}
|
35
|
+
|
36
|
+
static VALUE rb_git_remote__new(int argc, VALUE *argv, VALUE klass)
|
37
|
+
{
|
38
|
+
VALUE rb_remote, rb_repo, rb_url, rb_name;
|
39
|
+
git_remote *remote;
|
40
|
+
git_repository *repo;
|
41
|
+
const char *url;
|
42
|
+
int error;
|
43
|
+
|
44
|
+
rb_scan_args(argc, argv, "21", &rb_repo, &rb_url, &rb_name);
|
45
|
+
|
46
|
+
Check_Type(rb_url, T_STRING);
|
47
|
+
|
48
|
+
if (!rb_obj_is_instance_of(rb_repo, rb_cRuggedRepo))
|
49
|
+
rb_raise(rb_eTypeError, "Expecting a Rugged Repository");
|
50
|
+
|
51
|
+
Data_Get_Struct(rb_repo, git_repository, repo);
|
52
|
+
|
53
|
+
url = StringValueCStr(rb_url);
|
54
|
+
|
55
|
+
if (git_remote_valid_url(url)) {
|
56
|
+
if (!NIL_P(rb_name))
|
57
|
+
Check_Type(rb_name, T_STRING);
|
58
|
+
|
59
|
+
error = git_remote_new(
|
60
|
+
&remote,
|
61
|
+
repo,
|
62
|
+
StringValueCStr(rb_url),
|
63
|
+
NIL_P(rb_name) ? NULL : StringValueCStr(rb_name)
|
64
|
+
);
|
65
|
+
} else {
|
66
|
+
error = git_remote_load(&remote, repo, url);
|
67
|
+
}
|
68
|
+
|
69
|
+
rugged_exception_check(error);
|
70
|
+
|
71
|
+
rb_remote = Data_Wrap_Struct(klass, NULL, &rb_git_remote__free, remote);
|
72
|
+
rugged_set_owner(rb_remote, rb_repo);
|
73
|
+
return rb_remote;
|
74
|
+
}
|
75
|
+
|
76
|
+
static VALUE rb_git_remote_disconnect(VALUE self)
|
77
|
+
{
|
78
|
+
git_remote *remote;
|
79
|
+
Data_Get_Struct(self, git_remote, remote);
|
80
|
+
|
81
|
+
git_remote_disconnect(remote);
|
82
|
+
return Qnil;
|
83
|
+
}
|
84
|
+
|
85
|
+
static VALUE rb_git_remote_connect(VALUE self, VALUE rb_direction)
|
86
|
+
{
|
87
|
+
int error, direction = 0;
|
88
|
+
git_remote *remote;
|
89
|
+
ID id_direction;
|
90
|
+
|
91
|
+
Data_Get_Struct(self, git_remote, remote);
|
92
|
+
|
93
|
+
Check_Type(rb_direction, T_SYMBOL);
|
94
|
+
id_direction = SYM2ID(rb_direction);
|
95
|
+
|
96
|
+
if (id_direction == rb_intern("fetch"))
|
97
|
+
direction = GIT_DIR_FETCH;
|
98
|
+
else if (id_direction == rb_intern("push"))
|
99
|
+
direction = GIT_DIR_PUSH;
|
100
|
+
else
|
101
|
+
rb_raise(rb_eTypeError,
|
102
|
+
"Invalid remote direction. Expected `:fetch` or `:push`");
|
103
|
+
|
104
|
+
error = git_remote_connect(remote, direction);
|
105
|
+
rugged_exception_check(error);
|
106
|
+
|
107
|
+
if (rb_block_given_p())
|
108
|
+
rb_ensure(rb_yield, self, rb_git_remote_disconnect, self);
|
109
|
+
|
110
|
+
return Qnil;
|
111
|
+
}
|
112
|
+
|
113
|
+
static VALUE rugged_rhead_new(git_remote_head *head)
|
114
|
+
{
|
115
|
+
VALUE rb_head = rb_hash_new();
|
116
|
+
|
117
|
+
rb_hash_aset(rb_head, CSTR2SYM("local?"), head->local ? Qtrue : Qfalse);
|
118
|
+
rb_hash_aset(rb_head, CSTR2SYM("oid"), rugged_create_oid(&head->oid));
|
119
|
+
rb_hash_aset(rb_head, CSTR2SYM("loid"), rugged_create_oid(&head->loid));
|
120
|
+
rb_hash_aset(rb_head, CSTR2SYM("name"), rugged_str_new2(head->name, NULL));
|
121
|
+
|
122
|
+
return rb_head;
|
123
|
+
}
|
124
|
+
|
125
|
+
static int cb_remote__ls(git_remote_head *head, void *payload)
|
126
|
+
{
|
127
|
+
rb_funcall((VALUE)payload, rb_intern("call"), 1, rugged_rhead_new(head));
|
128
|
+
return GIT_SUCCESS;
|
129
|
+
}
|
130
|
+
|
131
|
+
static VALUE rb_git_remote_ls(VALUE self)
|
132
|
+
{
|
133
|
+
int error;
|
134
|
+
git_remote *remote;
|
135
|
+
Data_Get_Struct(self, git_remote, remote);
|
136
|
+
|
137
|
+
if (!rb_block_given_p())
|
138
|
+
return rb_funcall(self, rb_intern("to_enum"), 1, CSTR2SYM("ls"));
|
139
|
+
|
140
|
+
error = git_remote_ls(remote, &cb_remote__ls, (void *)rb_block_proc());
|
141
|
+
rugged_exception_check(error);
|
142
|
+
|
143
|
+
return Qnil;
|
144
|
+
}
|
145
|
+
|
146
|
+
static VALUE rb_git_remote_name(VALUE self)
|
147
|
+
{
|
148
|
+
git_remote *remote;
|
149
|
+
Data_Get_Struct(self, git_remote, remote);
|
150
|
+
|
151
|
+
return rugged_str_new2(git_remote_name(remote), NULL);
|
152
|
+
}
|
153
|
+
|
154
|
+
static VALUE rb_git_remote_url(VALUE self)
|
155
|
+
{
|
156
|
+
git_remote *remote;
|
157
|
+
Data_Get_Struct(self, git_remote, remote);
|
158
|
+
|
159
|
+
return rugged_str_new2(git_remote_url(remote), NULL);
|
160
|
+
}
|
161
|
+
|
162
|
+
static VALUE rb_git_remote_connected(VALUE self)
|
163
|
+
{
|
164
|
+
git_remote *remote;
|
165
|
+
Data_Get_Struct(self, git_remote, remote);
|
166
|
+
|
167
|
+
return git_remote_connected(remote) ? Qtrue : Qfalse;
|
168
|
+
}
|
169
|
+
|
170
|
+
static VALUE rb_git_remote_download(VALUE self)
|
171
|
+
{
|
172
|
+
int error;
|
173
|
+
git_remote *remote;
|
174
|
+
char *path;
|
175
|
+
VALUE rb_path;
|
176
|
+
|
177
|
+
Data_Get_Struct(self, git_remote, remote);
|
178
|
+
|
179
|
+
error = git_remote_download(&path, remote);
|
180
|
+
rugged_exception_check(error);
|
181
|
+
|
182
|
+
rb_path = rugged_str_new2(path, NULL);
|
183
|
+
free(path);
|
184
|
+
|
185
|
+
return rb_path;
|
186
|
+
}
|
187
|
+
|
188
|
+
static VALUE rb_git_remote_update_tips(VALUE self)
|
189
|
+
{
|
190
|
+
int error;
|
191
|
+
git_remote *remote;
|
192
|
+
|
193
|
+
Data_Get_Struct(self, git_remote, remote);
|
194
|
+
|
195
|
+
error = git_remote_update_tips(remote);
|
196
|
+
rugged_exception_check(error);
|
197
|
+
|
198
|
+
return Qnil;
|
199
|
+
}
|
200
|
+
|
201
|
+
void Init_rugged_remote()
|
202
|
+
{
|
203
|
+
rb_cRuggedRemote = rb_define_class_under(rb_mRugged, "Remote", rb_cObject);
|
204
|
+
|
205
|
+
rb_define_singleton_method(rb_cRuggedRemote, "new", rb_git_remote__new, -1);
|
206
|
+
|
207
|
+
rb_define_method(rb_cRuggedRemote, "connect", rb_git_remote_connect, 1);
|
208
|
+
rb_define_method(rb_cRuggedRemote, "disconnect", rb_git_remote_disconnect, 0);
|
209
|
+
rb_define_method(rb_cRuggedRemote, "name", rb_git_remote_name, 0);
|
210
|
+
rb_define_method(rb_cRuggedRemote, "url", rb_git_remote_url, 0);
|
211
|
+
rb_define_method(rb_cRuggedRemote, "connected?", rb_git_remote_connected, 0);
|
212
|
+
rb_define_method(rb_cRuggedRemote, "ls", rb_git_remote_ls, 0);
|
213
|
+
rb_define_method(rb_cRuggedRemote, "download", rb_git_remote_download, 0);
|
214
|
+
rb_define_method(rb_cRuggedRemote, "update_tips!", rb_git_remote_update_tips, 0);
|
215
|
+
}
|