elasticsearch-git 0.0.2 → 0.0.3
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 +16 -4
- data/lib/elasticsearch/git/repository.rb +21 -7
- data/lib/elasticsearch/git/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6dfec96f6e2fbded64a0429c7b083aadf96234b
|
4
|
+
data.tar.gz: 8eb678cf43ecbb8aeabc1016e00f3b721010f269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b88db3a9d3647bcd9c3eae1039e7b2380e51fcbf4b02b242e2bda5acc2cff8c58b8d2a1ad2941fedb586f3cfd318f9c9b386fa9bcdfeaeabdaef616c3c891f38
|
7
|
+
data.tar.gz: 5b2fa5f90008f048b33627724847ca317e36e766fdbc4e9e185e8ba26c7edc16a4d3981a5e6577c4943cfad45fe3825694728ca9eef8a3927414ef8466f9ca55
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Elasticsearch::Git
|
2
2
|
|
3
|
-
Attention: Pre-pre-pre beta code. Not production.
|
4
|
-
|
5
3
|
[Elasticsearch](https://github.com/elasticsearch/elasticsearch-rails/tree/master/elasticsearch-model) integrations for git repositories
|
6
4
|
|
7
5
|
## Installation
|
@@ -67,8 +65,20 @@ module RepositoriesSearch
|
|
67
65
|
project.id
|
68
66
|
end
|
69
67
|
end
|
70
|
-
end
|
71
68
|
|
69
|
+
module ClassMethods
|
70
|
+
def import
|
71
|
+
Repository.__elasticsearch__.create_index! force: true
|
72
|
+
|
73
|
+
Project.find_each do |project|
|
74
|
+
if project.repository.exists? && !project.repository.empty?
|
75
|
+
project.repository.index_commits
|
76
|
+
project.repository.index_blobs
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
72
82
|
|
73
83
|
# app/models/repository.rb
|
74
84
|
class Repository
|
@@ -80,7 +90,9 @@ class Repository
|
|
80
90
|
#...
|
81
91
|
end
|
82
92
|
|
83
|
-
|
93
|
+
Repository.import # for indexing all repositories
|
94
|
+
|
95
|
+
Repository.__elasticsearch__.create_index! force: true
|
84
96
|
Project.last.repository.index_commits
|
85
97
|
Project.last.repository.index_blobs
|
86
98
|
|
@@ -57,7 +57,9 @@ module Elasticsearch
|
|
57
57
|
|
58
58
|
if to_rev.present?
|
59
59
|
begin
|
60
|
-
|
60
|
+
if to_rev != "0000000000000000000000000000000000000000"
|
61
|
+
raise unless repository_for_indexing.lookup(to_rev).type == :commit
|
62
|
+
end
|
61
63
|
rescue
|
62
64
|
raise ArgumentError, "'to_rev': '#{to_rev}' is a incorrect commit sha."
|
63
65
|
end
|
@@ -69,7 +71,9 @@ module Elasticsearch
|
|
69
71
|
|
70
72
|
if from_rev.present?
|
71
73
|
begin
|
72
|
-
|
74
|
+
if from_rev != "0000000000000000000000000000000000000000"
|
75
|
+
raise unless repository_for_indexing.lookup(from_rev).type == :commit
|
76
|
+
end
|
73
77
|
rescue
|
74
78
|
raise ArgumentError, "'from_rev': '#{from_rev}' is a incorrect commit sha."
|
75
79
|
end
|
@@ -163,15 +167,25 @@ module Elasticsearch
|
|
163
167
|
#
|
164
168
|
# For search from commits use type 'commit'
|
165
169
|
def index_commits(from_rev: nil, to_rev: nil)
|
166
|
-
if
|
170
|
+
if to_rev.present?
|
167
171
|
begin
|
168
|
-
|
169
|
-
|
172
|
+
if from_rev.present? && from_rev != "0000000000000000000000000000000000000000"
|
173
|
+
raise unless repository_for_indexing.lookup(from_rev).type == :commit
|
174
|
+
end
|
175
|
+
if to_rev != "0000000000000000000000000000000000000000"
|
176
|
+
raise unless repository_for_indexing.lookup(to_rev).type == :commit
|
177
|
+
end
|
170
178
|
rescue
|
171
179
|
raise ArgumentError, "'from_rev': '#{from_rev}' is a incorrect commit sha."
|
172
180
|
end
|
173
181
|
|
174
|
-
|
182
|
+
walker = if from_rev == "0000000000000000000000000000000000000000" || from_rev.nil?
|
183
|
+
repository_for_indexing.walk(to_rev)
|
184
|
+
else
|
185
|
+
repository_for_indexing.walk(from_rev, to_rev)
|
186
|
+
end
|
187
|
+
|
188
|
+
walker.each do |commit|
|
175
189
|
index_commit(commit)
|
176
190
|
end
|
177
191
|
else
|
@@ -456,7 +470,7 @@ module Elasticsearch
|
|
456
470
|
private
|
457
471
|
|
458
472
|
def clean(message)
|
459
|
-
message.encode("UTF-16BE", :
|
473
|
+
message.encode("UTF-16BE", undef: :replace, invalid: :replace, replace: "")
|
460
474
|
.encode("UTF-8")
|
461
475
|
.gsub("\0".encode("UTF-8"), "")
|
462
476
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch-git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Kumanyaev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch-model
|