gitlab_git 7.1.2 → 7.1.3

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: bacaa31ceeb2b8f23f6bf232947ccb9abbf26ad7
4
- data.tar.gz: f25102377547ae8fcd83fdc133cbac40f73a3d80
3
+ metadata.gz: d14bd556fed0b0ad3ace6df4ac9c61a54972b878
4
+ data.tar.gz: aa8526169e2a983fea5f65f782911b5f030d0f17
5
5
  SHA512:
6
- metadata.gz: 840ea700a7453713acb0c67d795e4278462f09d9642f9da6926a3e0837b402e8274f699a338f0c5c8668feaa1e70a85222de55eafb09927abebff46c06d4aa25
7
- data.tar.gz: 6ddb2fe9ee8cdc7ac95f389c624666d626fb6e7649f675fc5495d9050291842d877ab053b88b89decd3cfa909918aa11aae6335bba0f60cb46e4cf4e772427a6
6
+ metadata.gz: 472f06e80a1bfb62907a1e620a95cd2fa6e99829ccd6622f7d68013bbb740ce6d161abc9f200808f947650ce4714415543c1b4771af020457c2f458ace95c0ae
7
+ data.tar.gz: 2d1739752f4fba1228b11ea5e8efb23bd5bbab8b9d7e113a21f4a6b5962a0d38eef815ebbb1567ddf49153d690e5a01a4cd73b9d3759ce3b7c7c722465b9b249
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.1.2
1
+ 7.1.3
@@ -172,16 +172,7 @@ module Gitlab
172
172
  #
173
173
  # Cuts out the header and stats from #to_patch and returns only the diff.
174
174
  def to_diff(options = {})
175
- patch = to_patch(options)
176
-
177
- # discard lines before the diff
178
- lines = patch.split("\n")
179
- while !lines.first.start_with?("diff --git") do
180
- lines.shift
181
- end
182
- lines.pop if lines.last =~ /^[\d.]+$/ # Git version
183
- lines.pop if lines.last == "-- " # end of diff
184
- lines.join("\n")
175
+ diff_from_parent(options).patch
185
176
  end
186
177
 
187
178
  # Returns a diff object for the changes from this commit's first parent.
@@ -229,7 +220,13 @@ module Gitlab
229
220
  end
230
221
 
231
222
  def to_patch(options = {})
232
- raw_commit.to_mbox(options)
223
+ begin
224
+ raw_commit.to_mbox(options)
225
+ rescue Rugged::InvalidError => ex
226
+ if ex.message =~ /Commit \w+ is a merge commit/
227
+ 'Patch format is not currently supported for merge commits.'
228
+ end
229
+ end
233
230
  end
234
231
 
235
232
  # Get a collection of Rugged::Reference objects for this commit.
@@ -135,57 +135,82 @@ module Gitlab
135
135
  #
136
136
  def archive_repo(ref, storage_path, format = "tar.gz")
137
137
  ref ||= root_ref
138
- commit = Gitlab::Git::Commit.find(self, ref)
139
- return nil unless commit
140
138
 
141
- extension = nil
142
- git_archive_format = nil
143
- pipe_cmd = nil
139
+ file_path = archive_file_path(ref, storage_path, format)
140
+ return nil unless file_path
141
+
142
+ return file_path if File.exist?(file_path)
144
143
 
145
144
  case format
146
145
  when "tar.bz2", "tbz", "tbz2", "tb2", "bz2"
147
- extension = ".tar.bz2"
148
146
  pipe_cmd = %W(bzip2)
149
147
  when "tar"
150
- extension = ".tar"
151
148
  pipe_cmd = %W(cat)
152
149
  when "zip"
153
- extension = ".zip"
154
150
  git_archive_format = "zip"
155
151
  pipe_cmd = %W(cat)
156
152
  else
157
153
  # everything else should fall back to tar.gz
158
- extension = ".tar.gz"
159
154
  git_archive_format = nil
160
155
  pipe_cmd = %W(gzip -n)
161
156
  end
162
157
 
163
- # Build file path
164
- file_name = self.name.gsub("\.git", "") + "-" + commit.id.to_s + extension
165
- file_path = File.join(storage_path, self.name, file_name)
166
-
167
- # Put files into a directory before archiving
168
- prefix = File.basename(self.name) + "/"
158
+ FileUtils.mkdir_p File.dirname(file_path)
169
159
 
170
- # Create file if not exists
171
- unless File.exists?(file_path)
172
- FileUtils.mkdir_p File.dirname(file_path)
160
+ pid_file_path = archive_pid_file_path(ref, storage_path, format)
161
+ return file_path if File.exist?(pid_file_path)
162
+
163
+ File.open(pid_file_path, "w") do |file|
164
+ file.puts Process.pid
165
+ end
173
166
 
174
- # Create the archive in temp file, to avoid leaving a corrupt archive
175
- # to be downloaded by the next user if we get interrupted while
176
- # creating the archive. Note that we do not care about cleaning up
177
- # the temp file in that scenario, because GitLab cleans up the
178
- # directory holding the archive files periodically.
179
- temp_file_path = file_path + ".#{Process.pid}-#{Time.now.to_i}"
180
- archive_to_file(ref, prefix, temp_file_path, git_archive_format, pipe_cmd)
167
+ # Create the archive in temp file, to avoid leaving a corrupt archive
168
+ # to be downloaded by the next user if we get interrupted while
169
+ # creating the archive.
170
+ temp_file_path = "#{file_path}.#{Process.pid}-#{Time.now.to_i}"
181
171
 
182
- # move temp file to persisted location
183
- FileUtils.move(temp_file_path, file_path)
172
+ begin
173
+ archive_to_file(ref, temp_file_path, git_archive_format, pipe_cmd)
174
+ rescue
175
+ FileUtils.rm(temp_file_path)
176
+ raise
177
+ ensure
178
+ FileUtils.rm(pid_file_path)
184
179
  end
185
180
 
181
+ # move temp file to persisted location
182
+ FileUtils.move(temp_file_path, file_path)
183
+
186
184
  file_path
187
185
  end
188
186
 
187
+ def archive_file_path(ref, storage_path, format = "tar.gz")
188
+ ref ||= root_ref
189
+ commit = Gitlab::Git::Commit.find(self, ref)
190
+ return nil unless commit
191
+
192
+ extension =
193
+ case format
194
+ when "tar.bz2", "tbz", "tbz2", "tb2", "bz2"
195
+ ".tar.bz2"
196
+ when "tar"
197
+ ".tar"
198
+ when "zip"
199
+ ".zip"
200
+ else
201
+ # everything else should fall back to tar.gz
202
+ ".tar.gz"
203
+ end
204
+
205
+ # Build file path
206
+ file_name = self.name.gsub("\.git", "") + "-" + commit.id.to_s + extension
207
+ File.join(storage_path, self.name, file_name)
208
+ end
209
+
210
+ def archive_pid_file_path(*args)
211
+ "#{archive_file_path(*args)}.pid"
212
+ end
213
+
189
214
  # Return repo size in megabytes
190
215
  def size
191
216
  size = popen(%W(du -s), path).first.strip.to_i
@@ -891,9 +916,13 @@ module Gitlab
891
916
  end
892
917
  end
893
918
 
894
- def archive_to_file(treeish = 'master', prefix = nil, filename = 'archive.tar.gz', format = nil, compress_cmd = %W(gzip))
919
+ def archive_to_file(treeish = 'master', filename = 'archive.tar.gz', format = nil, compress_cmd = %W(gzip))
895
920
  git_archive_cmd = %W(git --git-dir=#{path} archive)
896
- git_archive_cmd << "--prefix=#{prefix}" if prefix
921
+
922
+ # Put files into a directory before archiving
923
+ prefix = File.basename(self.name) + "/"
924
+ git_archive_cmd << "--prefix=#{prefix}"
925
+
897
926
  git_archive_cmd << "--format=#{format}" if format
898
927
  git_archive_cmd += %W(-- #{treeish})
899
928
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_git
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.2
4
+ version: 7.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Zaporozhets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-18 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab-linguist
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.4.5
111
+ rubygems_version: 2.2.2
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Gitlab::Git library