gitlab-grit 2.5.2 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of gitlab-grit might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/grit.rb +1 -1
- data/lib/grit/commit_stats.rb +1 -1
- data/lib/grit/git-ruby.rb +47 -43
- data/lib/grit/git.rb +3 -13
- data/lib/grit/repo.rb +3 -3
- data/lib/grit/status.rb +20 -21
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 290c31e6fb93fe5e1dd3c3f81e4f1a2438f00767
|
4
|
+
data.tar.gz: fda00dfa647aacbc021a1d2800750490a823ff27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fa89384e27c8bbbb6eac83b7062f4151be9009f852b4c2434ee2429f24ee21130694355e22662a41c9870602e91700bbccb6ac309da49bd73b66ab427fe8cad
|
7
|
+
data.tar.gz: bf0e2678fbe8c41dcbacd7a581b4e4f84132a58bb503111cf583c54400f2028fe99f2563b18a9fd03447d8bddb84e3ec796a63926eee742d0b6992f5aeee5715
|
data/README.md
CHANGED
data/lib/grit.rb
CHANGED
data/lib/grit/commit_stats.rb
CHANGED
@@ -68,7 +68,7 @@ module Grit
|
|
68
68
|
|
69
69
|
files = []
|
70
70
|
while lines.first =~ /^([-\d]+)\s+([-\d]+)\s+(.+)/
|
71
|
-
(additions, deletions, filename) = lines.shift.split
|
71
|
+
(additions, deletions, filename) = lines.shift.split(nil, 3)
|
72
72
|
additions = additions.to_i
|
73
73
|
deletions = deletions.to_i
|
74
74
|
total = additions + deletions
|
data/lib/grit/git-ruby.rb
CHANGED
@@ -116,27 +116,29 @@ module Grit
|
|
116
116
|
def refs(options, prefix)
|
117
117
|
refs = []
|
118
118
|
already = {}
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
119
|
+
orig_prefix = prefix
|
120
|
+
prefix = File.join @git_dir, prefix
|
121
|
+
|
122
|
+
files = Dir.glob(prefix + '/**/*')
|
123
|
+
files.each do |ref|
|
124
|
+
next if !File.file?(ref)
|
125
|
+
id = File.read(ref).chomp
|
126
|
+
name = ref.sub("#{prefix}/", '')
|
127
|
+
if !already[name]
|
128
|
+
refs << "#{name} #{id}"
|
129
|
+
already[name] = true
|
129
130
|
end
|
131
|
+
end
|
130
132
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
133
|
+
packed = File.join(@git_dir, 'packed-refs')
|
134
|
+
if File.file?(packed)
|
135
|
+
File.readlines(packed).each do |line|
|
136
|
+
if m = /^(\w{40}) (.*?)$/.match(line)
|
137
|
+
next if !Regexp.new('^' + orig_prefix).match(m[2])
|
138
|
+
name = m[2].sub("#{orig_prefix}/", '')
|
139
|
+
if !already[name]
|
140
|
+
refs << "#{name} #{m[1]}"
|
141
|
+
already[name] = true
|
140
142
|
end
|
141
143
|
end
|
142
144
|
end
|
@@ -149,43 +151,45 @@ module Grit
|
|
149
151
|
refs = []
|
150
152
|
already = {}
|
151
153
|
|
152
|
-
|
153
|
-
|
154
|
+
orig_prefix = prefix
|
155
|
+
prefix = File.join @git_dir, prefix
|
154
156
|
|
155
|
-
|
156
|
-
next if !File.file?(ref)
|
157
|
+
files = Dir.glob(prefix + '/**/*')
|
157
158
|
|
158
|
-
|
159
|
-
|
159
|
+
files.each do |ref|
|
160
|
+
next if !File.file?(ref)
|
160
161
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
id = File.read(ref).chomp
|
163
|
+
name = ref.sub("#{prefix}/", '')
|
164
|
+
|
165
|
+
if !already[name]
|
166
|
+
refs << "#{name} #{id}"
|
167
|
+
already[name] = true
|
165
168
|
end
|
169
|
+
end
|
166
170
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
171
|
+
packed = File.join(@git_dir, 'packed-refs')
|
172
|
+
if File.file?(packed)
|
173
|
+
lines = File.readlines('packed-refs')
|
174
|
+
lines.each_with_index do |line, i|
|
175
|
+
if m = /^(\w{40}) (.*?)$/.match(line)
|
176
|
+
next if !Regexp.new('^' + orig_prefix).match(m[2])
|
177
|
+
name = m[2].sub("#{orig_prefix}/", '')
|
173
178
|
|
174
|
-
|
175
|
-
|
176
|
-
|
179
|
+
# Annotated tags in packed-refs include a reference
|
180
|
+
# to the commit object on the following line.
|
181
|
+
next_line = lines[i + 1]
|
177
182
|
|
178
|
-
|
183
|
+
id =
|
179
184
|
if next_line && next_line[0] == ?^
|
180
185
|
next_line[1..-1].chomp
|
181
186
|
else
|
182
187
|
m[1]
|
183
188
|
end
|
184
189
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
end
|
190
|
+
if !already[name]
|
191
|
+
refs << "#{name} #{id}"
|
192
|
+
already[name] = true
|
189
193
|
end
|
190
194
|
end
|
191
195
|
end
|
data/lib/grit/git.rb
CHANGED
@@ -167,11 +167,7 @@ module Grit
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def list_remotes
|
170
|
-
remotes
|
171
|
-
Dir.chdir(File.join(self.git_dir, 'refs/remotes')) do
|
172
|
-
remotes = Dir.glob('*')
|
173
|
-
end
|
174
|
-
remotes
|
170
|
+
Dir.glob(File.join(self.git_dir, 'refs/remotes/*'))
|
175
171
|
rescue
|
176
172
|
[]
|
177
173
|
end
|
@@ -319,13 +315,10 @@ module Grit
|
|
319
315
|
env = options.delete(:env) || {}
|
320
316
|
raise_errors = options.delete(:raise)
|
321
317
|
process_info = options.delete(:process_info)
|
322
|
-
pipeline = options.delete(:pipeline)
|
323
318
|
|
324
319
|
# fall back to using a shell when the last argument looks like it wants to
|
325
320
|
# start a pipeline for compatibility with previous versions of grit.
|
326
|
-
if args[-1].to_s[0] == ?|
|
327
|
-
return run(prefix, cmd, '', options, args)
|
328
|
-
end
|
321
|
+
return run(prefix, cmd, '', options, args) if args[-1].to_s[0] == ?|
|
329
322
|
|
330
323
|
# more options
|
331
324
|
input = options.delete(:input)
|
@@ -421,10 +414,7 @@ module Grit
|
|
421
414
|
end
|
422
415
|
|
423
416
|
# DEPRECATED OPEN3-BASED COMMAND EXECUTION
|
424
|
-
|
425
|
-
# Ex.
|
426
|
-
# git log | grep bugfix
|
427
|
-
#
|
417
|
+
|
428
418
|
def run(prefix, cmd, postfix, options, args, &block)
|
429
419
|
timeout = options.delete(:timeout) rescue nil
|
430
420
|
timeout = true if timeout.nil?
|
data/lib/grit/repo.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module Grit
|
2
|
+
|
2
3
|
class Repo
|
3
4
|
DAEMON_EXPORT_FILE = 'git-daemon-export-ok'
|
4
5
|
BATCH_PARSERS = {
|
@@ -620,7 +621,6 @@ module Grit
|
|
620
621
|
def archive_tar_gz(treeish = 'master', prefix = nil)
|
621
622
|
options = {}
|
622
623
|
options[:prefix] = prefix if prefix
|
623
|
-
options[:pipeline] = true
|
624
624
|
self.git.archive(options, treeish, "| gzip -n")
|
625
625
|
end
|
626
626
|
|
@@ -636,7 +636,6 @@ module Grit
|
|
636
636
|
options = {}
|
637
637
|
options[:prefix] = prefix if prefix
|
638
638
|
options[:format] = format if format
|
639
|
-
options[:pipeline] = true
|
640
639
|
self.git.archive(options, treeish, "| #{pipe} > #{filename}")
|
641
640
|
end
|
642
641
|
|
@@ -716,7 +715,7 @@ module Grit
|
|
716
715
|
|
717
716
|
def grep(searchtext, contextlines = 3, branch = 'master')
|
718
717
|
context_arg = '-C ' + contextlines.to_s
|
719
|
-
result = git.native(:grep, {
|
718
|
+
result = git.native(:grep, {}, '-n', '-E', '-i', '-z', '--heading', '--break', context_arg, searchtext, branch).encode('UTF-8', invalid: :replace, undef: :replace, replace: '')
|
720
719
|
greps = []
|
721
720
|
filematches = result.split("\n\n")
|
722
721
|
filematches.each do |filematch|
|
@@ -757,4 +756,5 @@ module Grit
|
|
757
756
|
%Q{#<Grit::Repo "#{@path}">}
|
758
757
|
end
|
759
758
|
end # Repo
|
759
|
+
|
760
760
|
end # Grit
|
data/lib/grit/status.rb
CHANGED
@@ -90,34 +90,33 @@ module Grit
|
|
90
90
|
def construct_status
|
91
91
|
@files = ls_files
|
92
92
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
end
|
93
|
+
# find untracked in working dir
|
94
|
+
Dir.glob(File.join(@base.working_dir, '**/*')) do |full_file|
|
95
|
+
file = full_file.gsub "#{@base.working_dir}/", ""
|
96
|
+
if !@files[file]
|
97
|
+
@files[file] = {:path => file, :untracked => true} if !File.directory?(file)
|
99
98
|
end
|
99
|
+
end
|
100
100
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
101
|
+
# find modified in tree
|
102
|
+
diff_files.each do |path, data|
|
103
|
+
@files[path] ? @files[path].merge!(data) : @files[path] = data
|
104
|
+
end
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
106
|
+
# find added but not committed - new files
|
107
|
+
diff_index('HEAD').each do |path, data|
|
108
|
+
@files[path] ? @files[path].merge!(data) : @files[path] = data
|
109
|
+
end
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
end
|
111
|
+
@files.each do |k, file_hash|
|
112
|
+
@files[k] = StatusFile.new(@base, file_hash)
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
117
116
|
# compares the index and the working directory
|
118
117
|
def diff_files
|
119
118
|
hsh = {}
|
120
|
-
@base.git.diff_files.split("\n").each do |line|
|
119
|
+
@base.git.diff_files(chdir: @base.working_dir).split("\n").each do |line|
|
121
120
|
(info, file) = line.split("\t")
|
122
121
|
(mode_src, mode_dest, sha_src, sha_dest, type) = info.split
|
123
122
|
hsh[file] = {:path => file, :mode_file => mode_src.to_s[1, 7], :mode_index => mode_dest,
|
@@ -129,7 +128,7 @@ module Grit
|
|
129
128
|
# compares the index and the repository
|
130
129
|
def diff_index(treeish)
|
131
130
|
hsh = {}
|
132
|
-
@base.git.diff_index({}, treeish).split("\n").each do |line|
|
131
|
+
@base.git.diff_index({chdir: @base.working_dir}, treeish).split("\n").each do |line|
|
133
132
|
(info, file) = line.split("\t")
|
134
133
|
(mode_src, mode_dest, sha_src, sha_dest, type) = info.split
|
135
134
|
hsh[file] = {:path => file, :mode_repo => mode_src.to_s[1, 7], :mode_index => mode_dest,
|
@@ -140,7 +139,7 @@ module Grit
|
|
140
139
|
|
141
140
|
def ls_files
|
142
141
|
hsh = {}
|
143
|
-
lines = @base.git.ls_files({:stage => true})
|
142
|
+
lines = @base.git.ls_files({chdir: @base.working_dir, :stage => true})
|
144
143
|
lines.split("\n").each do |line|
|
145
144
|
(info, file) = line.split("\t")
|
146
145
|
(mode, sha, stage) = info.split
|
@@ -150,4 +149,4 @@ module Grit
|
|
150
149
|
end
|
151
150
|
end
|
152
151
|
|
153
|
-
end
|
152
|
+
end
|