rjgit 6.4.0.0 → 6.4.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.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/commit.rb +15 -0
- data/lib/note.rb +18 -0
- data/lib/repo.rb +6 -0
- data/lib/rjgit_helpers.rb +13 -5
- data/lib/version.rb +1 -1
- 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: 6ee86efc7cf49616791f74a2d0781cd3bd2bf4e570d0353c5c71b012b984230a
|
4
|
+
data.tar.gz: 6a87141e15f7c413f1d1d6205d9e5898e1e8e0d97183569f8bee2807ab0eb9d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fca1bb945ad86907e0c65d1a7ce726cc6ab0f1c7a49040c52162b5b0f54c6449c67b70c13022954420912d5fba0a4104fbcbbdd563a43fa54ea241551084fb2
|
7
|
+
data.tar.gz: 3df8fe32b4c38c14515eaa4e0800e21aed95a1106964f49fbe6148c85699a72b4e4296be51c2d210f1e8efd4eda60d2e26205fba0a01e485f8e156330397c630
|
data/README.md
CHANGED
@@ -67,6 +67,19 @@ repo.commits('master')
|
|
67
67
|
repo.commits('959329025f67539fb82e76b02782322fad032821')
|
68
68
|
repo.head
|
69
69
|
commit = repo.commits('master').first # a Commit object; try commit.actor, commit.id, etc.
|
70
|
+
```
|
71
|
+
|
72
|
+
### Getting notes
|
73
|
+
```ruby
|
74
|
+
repo.notes
|
75
|
+
note = repo.head.note
|
76
|
+
note.message # the String message of the note
|
77
|
+
note.annotates # the SHA ID of the object this note is attached to
|
78
|
+
repo.head.note = "Happy note writing"
|
79
|
+
repo.head.note_remove
|
80
|
+
```
|
81
|
+
|
82
|
+
|
70
83
|
# Similarly for getting tags, branches, trees (directories), and blobs (files).
|
71
84
|
```
|
72
85
|
|
data/lib/commit.rb
CHANGED
@@ -4,6 +4,7 @@ module RJGit
|
|
4
4
|
import 'org.eclipse.jgit.revwalk.RevCommit'
|
5
5
|
import 'org.eclipse.jgit.diff.DiffFormatter'
|
6
6
|
import 'org.eclipse.jgit.util.io.DisabledOutputStream'
|
7
|
+
import 'org.eclipse.jgit.api.Git'
|
7
8
|
|
8
9
|
class Commit
|
9
10
|
|
@@ -30,6 +31,20 @@ module RJGit
|
|
30
31
|
@tree ||= Tree.new(@jrepo, TREE_TYPE, nil, @jcommit.get_tree)
|
31
32
|
end
|
32
33
|
|
34
|
+
def note(ref=Note::DEFAULT_REF)
|
35
|
+
jnote = Git.new(@jrepo).notes_show().set_notes_ref(ref).setObjectId(@jcommit).call()
|
36
|
+
jnote ? Note.new(@jrepo, jnote) : nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def note=(message, ref=Note::DEFAULT_REF)
|
40
|
+
Note.new(@jrepo, Git.new(@jrepo).notes_add.set_message(message).set_notes_ref(ref).setObjectId(@jcommit).call())
|
41
|
+
end
|
42
|
+
|
43
|
+
def remove_note(ref=Note::DEFAULT_REF)
|
44
|
+
Git.new(@jrepo).notes_remove.set_notes_ref(ref).setObjectId(@jcommit).call()
|
45
|
+
return nil
|
46
|
+
end
|
47
|
+
|
33
48
|
def parents
|
34
49
|
@parents ||= @jcommit.get_parents.map do |parent|
|
35
50
|
RJGit::Commit.new(@jrepo, RevWalk.new(@jrepo).parseCommit(parent.get_id))
|
data/lib/note.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module RJGit
|
2
|
+
|
3
|
+
class Note
|
4
|
+
attr_reader :jnote, :message, :annotates
|
5
|
+
DEFAULT_REF = "refs/notes/commits"
|
6
|
+
|
7
|
+
def initialize(repository, note)
|
8
|
+
@jrepo = RJGit.repository_type(repository)
|
9
|
+
@jnote = RJGit.note_type(note)
|
10
|
+
@message = @jrepo.open(@jnote.getData()).get_bytes.to_a.pack('c*').force_encoding('UTF-8')
|
11
|
+
@annotates = @jnote.to_s[5..44]
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
@message
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/repo.rb
CHANGED
@@ -216,6 +216,12 @@ module RJGit
|
|
216
216
|
def tree(file_path, revstring=Constants::HEAD)
|
217
217
|
Tree.find_tree(@jrepo, file_path, revstring)
|
218
218
|
end
|
219
|
+
|
220
|
+
def notes(ref=Note::DEFAULT_REF)
|
221
|
+
@git.jgit.notes_list().set_notes_ref(ref).call().to_a.map do |jnote|
|
222
|
+
Note.new(@jrepo, jnote)
|
223
|
+
end
|
224
|
+
end
|
219
225
|
|
220
226
|
def update_ref(commit, force = false, ref = "refs/heads/#{Constants::MASTER}")
|
221
227
|
ref_updater = @jrepo.updateRef(ref)
|
data/lib/rjgit_helpers.rb
CHANGED
@@ -83,7 +83,7 @@ module RJGit
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def self.repository_type(repository)
|
86
|
-
|
86
|
+
case repository
|
87
87
|
when Repo then repository.jrepo
|
88
88
|
when org.eclipse.jgit.lib.Repository then repository
|
89
89
|
else nil
|
@@ -91,7 +91,7 @@ module RJGit
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def self.actor_type(actor)
|
94
|
-
|
94
|
+
case actor
|
95
95
|
when Actor then actor.person_ident
|
96
96
|
when org.eclipse.jgit.lib.PersonIdent then actor
|
97
97
|
else nil
|
@@ -99,7 +99,7 @@ module RJGit
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def self.tree_type(tree)
|
102
|
-
|
102
|
+
case tree
|
103
103
|
when Tree then tree.jtree
|
104
104
|
when org.eclipse.jgit.revwalk.RevTree then tree
|
105
105
|
when org.eclipse.jgit.lib.ObjectId then tree
|
@@ -108,15 +108,23 @@ module RJGit
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def self.blob_type(blob)
|
111
|
-
|
111
|
+
case blob
|
112
112
|
when Blob then blob.jblob
|
113
113
|
when org.eclipse.jgit.revwalk.RevBlob then blob
|
114
114
|
else nil
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
|
+
def self.note_type(note)
|
119
|
+
case note
|
120
|
+
when Note then note.jnote
|
121
|
+
when org.eclipse.jgit.notes.Note then note
|
122
|
+
else nil
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
118
126
|
def self.commit_type(commit)
|
119
|
-
|
127
|
+
case commit
|
120
128
|
when Commit then commit.jcommit
|
121
129
|
when org.eclipse.jgit.lib.ObjectId then commit
|
122
130
|
else nil
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.4.0.
|
4
|
+
version: 6.4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maarten Engelen
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/java/jars/org.eclipse.jgit.ssh.jsch-6.2.0.202206071550-r.jar
|
54
54
|
- lib/java/jars/slf4j-api-1.7.2.jar
|
55
55
|
- lib/java/jars/slf4j-simple-1.7.12.jar
|
56
|
+
- lib/note.rb
|
56
57
|
- lib/repo.rb
|
57
58
|
- lib/rjgit.rb
|
58
59
|
- lib/rjgit_helpers.rb
|