gitlab_git 7.0.0.rc7 → 7.0.0.rc8
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/VERSION +1 -1
- data/lib/gitlab_git.rb +0 -1
- data/lib/gitlab_git/repository.rb +43 -70
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73f18b742e441f8974c658139ba8e543bfea6f46
|
4
|
+
data.tar.gz: 35e4be4dc66c78ff87694794deec5f394666e9d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77de354a1a19bf8bb5588946e3d705a97c4f87b2712e610f9dfd5298c7bc72b6ebbaa34a77c36f82a9d090f49215099311121c8c944e5386090fa52702dc81d9
|
7
|
+
data.tar.gz: f29427c0a612a57cabf3e6988f30fd276778c9c28732563ad0a404450dea2cd5d650f3de81f42a4752ba141903ccbab1070dcf5392eae2f6d0ea10f91cef349b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.0.0.
|
1
|
+
7.0.0.rc8
|
data/lib/gitlab_git.rb
CHANGED
@@ -22,6 +22,8 @@ module Gitlab
|
|
22
22
|
# Rugged repo object
|
23
23
|
attr_reader :rugged
|
24
24
|
|
25
|
+
# 'path' must be the path to a _bare_ git repository, e.g.
|
26
|
+
# /path/to/my-repo.git
|
25
27
|
def initialize(path)
|
26
28
|
@path = path
|
27
29
|
@name = path.split("/").last
|
@@ -131,6 +133,7 @@ module Gitlab
|
|
131
133
|
return nil unless commit
|
132
134
|
|
133
135
|
extension = nil
|
136
|
+
git_archive_format = nil
|
134
137
|
pipe_cmd = nil
|
135
138
|
|
136
139
|
case format
|
@@ -142,10 +145,12 @@ module Gitlab
|
|
142
145
|
pipe_cmd = %W(cat)
|
143
146
|
when "zip"
|
144
147
|
extension = ".zip"
|
148
|
+
git_archive_format = "zip"
|
145
149
|
pipe_cmd = %W(cat)
|
146
150
|
else
|
147
151
|
# everything else should fall back to tar.gz
|
148
152
|
extension = ".tar.gz"
|
153
|
+
git_archive_format = nil
|
149
154
|
pipe_cmd = %W(gzip -n)
|
150
155
|
end
|
151
156
|
|
@@ -153,12 +158,24 @@ module Gitlab
|
|
153
158
|
file_name = self.name.gsub("\.git", "") + "-" + commit.id.to_s + extension
|
154
159
|
file_path = File.join(storage_path, self.name, file_name)
|
155
160
|
|
156
|
-
#
|
157
|
-
|
158
|
-
FileUtils.mkdir_p(parent_path) unless File.directory?(parent_path)
|
161
|
+
# Put files into a directory before archiving
|
162
|
+
prefix = File.basename(self.name) + "/"
|
159
163
|
|
160
164
|
# Create file if not exists
|
161
|
-
|
165
|
+
unless File.exists?(file_path)
|
166
|
+
FileUtils.mkdir_p File.dirname(file_path)
|
167
|
+
|
168
|
+
# Create the archive in temp file, to avoid leaving a corrupt archive
|
169
|
+
# to be downloaded by the next user if we get interrupted while
|
170
|
+
# creating the archive. Note that we do not care about cleaning up
|
171
|
+
# the temp file in that scenario, because GitLab cleans up the
|
172
|
+
# directory holding the archive files periodically.
|
173
|
+
temp_file_path = file_path + ".#{Process.pid}-#{Time.now.to_i}"
|
174
|
+
archive_to_file(ref, prefix, temp_file_path, git_archive_format, pipe_cmd)
|
175
|
+
|
176
|
+
# move temp file to persisted location
|
177
|
+
FileUtils.move(temp_file_path, file_path)
|
178
|
+
end
|
162
179
|
|
163
180
|
file_path
|
164
181
|
end
|
@@ -816,79 +833,35 @@ module Gitlab
|
|
816
833
|
end
|
817
834
|
end
|
818
835
|
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
if extension == '.zip'
|
826
|
-
create_zip_archive(ref_name, file_path, prefix)
|
827
|
-
else
|
828
|
-
# Open the file with the final result
|
829
|
-
FileUtils.mkdir_p(Pathname.new(file_path).dirname)
|
830
|
-
archive_file = File.new(file_path, 'wb')
|
836
|
+
def archive_to_file(treeish = 'master', prefix = nil, filename = 'archive.tar.gz', format = nil, compress_cmd = %W(gzip))
|
837
|
+
git_archive_cmd = %W(git --git-dir=#{path} archive)
|
838
|
+
git_archive_cmd << "--prefix=#{prefix}" if prefix
|
839
|
+
git_archive_cmd << "--format=#{format}" if format
|
840
|
+
git_archive_cmd += %W(-- #{treeish})
|
831
841
|
|
832
|
-
|
842
|
+
open(filename, 'w') do |file|
|
843
|
+
# Create a pipe to act as the '|' in 'git archive ... | gzip'
|
833
844
|
pipe_rd, pipe_wr = IO.pipe
|
834
|
-
compress_pid = spawn(*pipe_cmd, in: pipe_rd, out: archive_file)
|
835
|
-
# pipe_rd and archive_file belong to the compressor process now; close
|
836
|
-
# them straightaway in our process.
|
837
|
-
pipe_rd.close
|
838
|
-
archive_file.close
|
839
845
|
|
840
|
-
#
|
841
|
-
#
|
842
|
-
|
843
|
-
|
844
|
-
|
846
|
+
# Get the compression process ready to accept data from the read end
|
847
|
+
# of the pipe
|
848
|
+
compress_pid = spawn(*compress_cmd, :in => pipe_rd, :out => file)
|
849
|
+
# The read end belongs to the compression process now; we should
|
850
|
+
# close our file descriptor for it.
|
851
|
+
pipe_rd.close
|
845
852
|
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
end
|
850
|
-
# We are done with pipe_wr, close it straightaway.
|
853
|
+
# Start 'git archive' and tell it to write into the write end of the
|
854
|
+
# pipe.
|
855
|
+
git_archive_pid = spawn(*git_archive_cmd, :out => pipe_wr)
|
856
|
+
# The write end belongs to 'git archive' now; close it.
|
851
857
|
pipe_wr.close
|
852
858
|
|
859
|
+
# When 'git archive' and the compression process are finished, we are
|
860
|
+
# done.
|
861
|
+
Process.waitpid(git_archive_pid)
|
862
|
+
raise "#{git_archive_cmd.join(' ')} failed" unless $?.success?
|
853
863
|
Process.waitpid(compress_pid)
|
854
|
-
|
855
|
-
end
|
856
|
-
|
857
|
-
# Create a zip file with the contents of the repo
|
858
|
-
def create_zip_archive(ref_name, archive_path, prefix)
|
859
|
-
Zip::File.open(archive_path, Zip::File::CREATE) do |zipfile|
|
860
|
-
populated_index(ref_name).each do |entry|
|
861
|
-
add_archive_entry(zipfile, prefix, entry)
|
862
|
-
end
|
863
|
-
end
|
864
|
-
end
|
865
|
-
|
866
|
-
# Add a file or directory from the index to the given tar or zip file
|
867
|
-
def add_archive_entry(archive, prefix, entry)
|
868
|
-
prefixed_path = File.join(prefix, entry[:path])
|
869
|
-
|
870
|
-
if submodule?(entry)
|
871
|
-
# Create an empty directory for submodules
|
872
|
-
mask = case archive
|
873
|
-
when Zip::File then 0755
|
874
|
-
else '100755'.to_i(8)
|
875
|
-
end
|
876
|
-
archive.mkdir(prefixed_path, mask)
|
877
|
-
else
|
878
|
-
blob = rugged.lookup(entry[:oid])
|
879
|
-
content = blob.content
|
880
|
-
|
881
|
-
# Write the blob contents to the archive
|
882
|
-
if archive.is_a?(Zip::File)
|
883
|
-
archive.get_output_stream(prefixed_path) do |os|
|
884
|
-
os.write(content)
|
885
|
-
end
|
886
|
-
else
|
887
|
-
archive.add_file_simple(prefixed_path,
|
888
|
-
entry[:mode], blob.size) do |tf|
|
889
|
-
tf.write(content)
|
890
|
-
end
|
891
|
-
end
|
864
|
+
raise "#{compress_cmd.join(' ')} failed" unless $?.success?
|
892
865
|
end
|
893
866
|
end
|
894
867
|
|
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.0.0.
|
4
|
+
version: 7.0.0.rc8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Zaporozhets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab-linguist
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.6'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rubyzip
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.1'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.1'
|
83
69
|
description: GitLab wrapper around git objects
|
84
70
|
email: dmitriy.zaporozhets@gmail.com
|
85
71
|
executables: []
|