simple_git 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/lib/simple_git/reference.rb +51 -0
- data/lib/simple_git/repository.rb +4 -0
- data/lib/simple_git/version.rb +1 -1
- data/lib/simple_git.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 040b27ee12f2afa0136ffc8c7ce4aee21028dbe358fc889f05df5ddc4d02adb0
|
4
|
+
data.tar.gz: 8510882d86800026c0f88cebf145a9b9d94518b950d9637180d4772087749f95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fac2194a0218cd74eda5c8af59e3d8dfbe7955b5388cb8a9f5625301aedb7e1aa93ca8ef60f142fd770e19cdc46416c2794595c85b56607bcd3d305524003878
|
7
|
+
data.tar.gz: e8b563d54120f50ca79fc5614c2749ec3fb755eed57e1a2c9ce0b02c7b54fdc4095a9c1a1d43a58e5b919d838d960241c4d99d3c8efe4d243084ad583822b59d
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module SimpleGit
|
2
|
+
class Reference
|
3
|
+
attr_accessor :ptr
|
4
|
+
|
5
|
+
def from_head(repo)
|
6
|
+
wrapper = ReferenceWrapper.new
|
7
|
+
ret = Git2.git_repository_head(wrapper, repo.ptr)
|
8
|
+
if ret != 0
|
9
|
+
error = Git2::GitError.new(Git2.giterr_last)
|
10
|
+
raise ArgumentError, error[:message].read_string
|
11
|
+
end
|
12
|
+
|
13
|
+
@ptr = wrapper[:ref]
|
14
|
+
ObjectSpace.define_finalizer(self, self.class.finalize(@ptr))
|
15
|
+
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def branch_name
|
20
|
+
name_wrapper = FFI::MemoryPointer.new(:pointer)
|
21
|
+
ret = Git2.git_branch_name(name_wrapper, @ptr)
|
22
|
+
if ret != 0
|
23
|
+
error = Git2::GitError.new(Git2.giterr_last)
|
24
|
+
raise ArgumentError, error[:message].read_string
|
25
|
+
end
|
26
|
+
|
27
|
+
name_wrapper.read_pointer.read_string
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_object
|
31
|
+
wrapper = SimpleGit::Object::ObjectWrapper.new
|
32
|
+
ret = Git2.git_reference_peel(wrapper, @ptr, :GIT_OBJ_ANY)
|
33
|
+
if ret != 0
|
34
|
+
error = Git2::GitError.new(Git2.giterr_last)
|
35
|
+
raise ArgumentError, error[:message].read_string
|
36
|
+
end
|
37
|
+
|
38
|
+
Object.new.from_wrapper(wrapper)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def self.finalize(ptr)
|
44
|
+
proc { Git2.git_reference_free(ptr) }
|
45
|
+
end
|
46
|
+
|
47
|
+
class ReferenceWrapper < FFI::Struct
|
48
|
+
layout :ref, Git2::GitReference.by_ref
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/simple_git/version.rb
CHANGED
data/lib/simple_git.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liam P. White
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/simple_git/diff_stat.rb
|
41
41
|
- lib/simple_git/object.rb
|
42
42
|
- lib/simple_git/oid.rb
|
43
|
+
- lib/simple_git/reference.rb
|
43
44
|
- lib/simple_git/repository.rb
|
44
45
|
- lib/simple_git/revwalk.rb
|
45
46
|
- lib/simple_git/signature.rb
|