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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e01843f1f907d4f805ebe1a462b2b9ef8d9eaab5
4
- data.tar.gz: b9f43ffa1683eaf547231ed43669af157f8164c4
3
+ metadata.gz: 290c31e6fb93fe5e1dd3c3f81e4f1a2438f00767
4
+ data.tar.gz: fda00dfa647aacbc021a1d2800750490a823ff27
5
5
  SHA512:
6
- metadata.gz: b24104f75bfe51628548effd17d98df9f5a0afd5b21b78e46014dfdfaec6429e6af233b8e6eb23c0d94854886a4129cb06b046c1b0995e59575a0ba950e4f8a9
7
- data.tar.gz: f2d909494083105615098ff61a57da78b7ff4a041b214286fb5c3d5b0c5a0cb1717d8b71e9fddb7d8909fe7bd70e9a1115fdb71d1e46bb94cbc696eb31247941
6
+ metadata.gz: 9fa89384e27c8bbbb6eac83b7062f4151be9009f852b4c2434ee2429f24ee21130694355e22662a41c9870602e91700bbccb6ac309da49bd73b66ab427fe8cad
7
+ data.tar.gz: bf0e2678fbe8c41dcbacd7a581b4e4f84132a58bb503111cf583c54400f2028fe99f2563b18a9fd03447d8bddb84e3ec796a63926eee742d0b6992f5aeee5715
data/README.md CHANGED
@@ -31,7 +31,7 @@ This documentation is accurate as of Grit 2.3.
31
31
 
32
32
  ## Requirements
33
33
 
34
- * git (http://git-scm.com) tested with 1.7.2.1
34
+ * git (http://git-scm.com) tested with 1.7.4.6
35
35
 
36
36
 
37
37
  ## Install
@@ -50,7 +50,7 @@ require 'grit/merge'
50
50
  require 'grit/grep'
51
51
 
52
52
  module Grit
53
- VERSION = '2.5.0'
53
+ VERSION = '2.6.0'
54
54
 
55
55
  class << self
56
56
  # Set +debug+ to true to log all git calls and responses
@@ -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
@@ -116,27 +116,29 @@ module Grit
116
116
  def refs(options, prefix)
117
117
  refs = []
118
118
  already = {}
119
- Dir.chdir(@git_dir) do
120
- files = Dir.glob(prefix + '/**/*')
121
- files.each do |ref|
122
- next if !File.file?(ref)
123
- id = File.read(ref).chomp
124
- name = ref.sub("#{prefix}/", '')
125
- if !already[name]
126
- refs << "#{name} #{id}"
127
- already[name] = true
128
- end
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
- if File.file?('packed-refs')
132
- File.readlines('packed-refs').each do |line|
133
- if m = /^(\w{40}) (.*?)$/.match(line)
134
- next if !Regexp.new('^' + prefix).match(m[2])
135
- name = m[2].sub("#{prefix}/", '')
136
- if !already[name]
137
- refs << "#{name} #{m[1]}"
138
- already[name] = true
139
- end
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
- Dir.chdir(repo.path) do
153
- files = Dir.glob(prefix + '/**/*')
154
+ orig_prefix = prefix
155
+ prefix = File.join @git_dir, prefix
154
156
 
155
- files.each do |ref|
156
- next if !File.file?(ref)
157
+ files = Dir.glob(prefix + '/**/*')
157
158
 
158
- id = File.read(ref).chomp
159
- name = ref.sub("#{prefix}/", '')
159
+ files.each do |ref|
160
+ next if !File.file?(ref)
160
161
 
161
- if !already[name]
162
- refs << "#{name} #{id}"
163
- already[name] = true
164
- end
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
- if File.file?('packed-refs')
168
- lines = File.readlines('packed-refs')
169
- lines.each_with_index do |line, i|
170
- if m = /^(\w{40}) (.*?)$/.match(line)
171
- next if !Regexp.new('^' + prefix).match(m[2])
172
- name = m[2].sub("#{prefix}/", '')
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
- # Annotated tags in packed-refs include a reference
175
- # to the commit object on the following line.
176
- next_line = lines[i + 1]
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
- id =
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
- if !already[name]
186
- refs << "#{name} #{id}"
187
- already[name] = true
188
- end
190
+ if !already[name]
191
+ refs << "#{name} #{id}"
192
+ already[name] = true
189
193
  end
190
194
  end
191
195
  end
@@ -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] == ?| && pipeline
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
- # Used only for pipeline support.
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?
@@ -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, {pipeline: false}, '-n', '-E', '-i', '-z', '--heading', '--break', context_arg, searchtext, branch).force_encoding('UTF-8')
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
@@ -90,34 +90,33 @@ module Grit
90
90
  def construct_status
91
91
  @files = ls_files
92
92
 
93
- Dir.chdir(@base.working_dir) do
94
- # find untracked in working dir
95
- Dir.glob('**/*') do |file|
96
- if !@files[file]
97
- @files[file] = {:path => file, :untracked => true} if !File.directory?(file)
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
- # find modified in tree
102
- diff_files.each do |path, data|
103
- @files[path] ? @files[path].merge!(data) : @files[path] = data
104
- end
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
- # 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
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
- @files.each do |k, file_hash|
112
- @files[k] = StatusFile.new(@base, file_hash)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-grit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner