gitlab_git 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d8d13a9a393763fd7569f4eb2542aaaace4f82a
4
- data.tar.gz: 2eb533597ff16b061169cd8c2c5d1890f1171492
3
+ metadata.gz: d92ad017d5727df20007d2885c601164cfe25c67
4
+ data.tar.gz: 6be7a8673db16fc333635b7ec4f8904525130577
5
5
  SHA512:
6
- metadata.gz: d0c930ac693ae587b6870baa0c47550281b8c73277b5c87a4cd3afe7dc59f10811b7cc9e5ce916d3ebe7861990693feb4b96a881c100da7c2df599030f51750f
7
- data.tar.gz: 720844c0a7daca609101d1626b01c642f7c320912f6540688e68e9671b7d13dc166f1c46c40b6e5b3ae22ce4692feddeea0eb82f61618869fea53c1f89fa1e1e
6
+ metadata.gz: c2fd4d0ca47e49227989288acdd27c6b53f9925311cf2b71f9fafac644254fbf1136fc619a49f07a6eb750c9dea80052912fe412168d377425a0593863ec742c
7
+ data.tar.gz: fd7102433138e7774a9dcaf520cb5bb73afe3e05ef8ecfd5cfd171c9122f8651ecb845bf3363fdbfb557882a9b63c77a888982f60199fc324f610474f2a1cf12
data/lib/gitlab_git.rb CHANGED
@@ -21,3 +21,4 @@ require_relative "gitlab_git/diff"
21
21
  require_relative "gitlab_git/repository"
22
22
  require_relative "gitlab_git/stats"
23
23
  require_relative "gitlab_git/tree"
24
+ require_relative "gitlab_git/blob_snippet"
@@ -0,0 +1,32 @@
1
+ module Gitlab
2
+ module Git
3
+ class BlobSnippet
4
+ include Linguist::BlobHelper
5
+
6
+ attr_accessor :ref
7
+ attr_accessor :lines
8
+ attr_accessor :filename
9
+ attr_accessor :startline
10
+
11
+ def initialize(ref, lines, startline, filename)
12
+ @ref, @lines, @startline, @filename = ref, lines, startline, filename
13
+ end
14
+
15
+ def data
16
+ lines.join("\n")
17
+ end
18
+
19
+ def name
20
+ filename
21
+ end
22
+
23
+ def size
24
+ data.length
25
+ end
26
+
27
+ def mode
28
+ nil
29
+ end
30
+ end
31
+ end
32
+ end
@@ -203,6 +203,18 @@ module Gitlab
203
203
  [Gitlab::Git::Diff::BROKEN_DIFF]
204
204
  end
205
205
 
206
+ def search_files(query, ref = nil)
207
+ if ref.nil? || ref == ""
208
+ ref = root_ref
209
+ end
210
+
211
+ greps = repo.grep(query, 3, ref)
212
+
213
+ greps.map do |grep|
214
+ Gitlab::Git::BlobSnippet.new(ref, grep.content, grep.startline, grep.filename)
215
+ end
216
+ end
217
+
206
218
  protected
207
219
 
208
220
  def decorate_commit(commit, ref = nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Zaporozhets
@@ -75,6 +75,7 @@ files:
75
75
  - lib/gitlab_git.rb
76
76
  - lib/gitlab_git/blame.rb
77
77
  - lib/gitlab_git/blob.rb
78
+ - lib/gitlab_git/blob_snippet.rb
78
79
  - lib/gitlab_git/commit.rb
79
80
  - lib/gitlab_git/compare.rb
80
81
  - lib/gitlab_git/diff.rb
@@ -83,7 +84,8 @@ files:
83
84
  - lib/gitlab_git/stats.rb
84
85
  - lib/gitlab_git/tree.rb
85
86
  homepage: http://rubygems.org/gems/gitlab_git
86
- licenses: []
87
+ licenses:
88
+ - MIT
87
89
  metadata: {}
88
90
  post_install_message:
89
91
  rdoc_options: []
@@ -101,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
103
  version: '0'
102
104
  requirements: []
103
105
  rubyforge_project:
104
- rubygems_version: 2.0.0.rc.2
106
+ rubygems_version: 2.0.3
105
107
  signing_key:
106
108
  specification_version: 4
107
109
  summary: Gitlab::Git library