autobuild 1.7.11.rc1 → 1.7.11.rc2
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.
- data/lib/autobuild/import/archive.rb +8 -1
- data/lib/autobuild/import/git.rb +48 -9
- data/lib/autobuild/version.rb +1 -1
- metadata +2 -2
|
@@ -189,7 +189,14 @@ module Autobuild
|
|
|
189
189
|
# The directory in which remote files are cached
|
|
190
190
|
#
|
|
191
191
|
# Defaults to ArchiveImporter.cachedir
|
|
192
|
-
|
|
192
|
+
attr_reader :cachedir
|
|
193
|
+
|
|
194
|
+
# Changes the cache directory for this importer
|
|
195
|
+
def cachedir=(dir)
|
|
196
|
+
@cachedir = dir
|
|
197
|
+
relocate(@url.to_s)
|
|
198
|
+
end
|
|
199
|
+
|
|
193
200
|
# The directory contained in the tar file
|
|
194
201
|
#
|
|
195
202
|
# DEPRECATED use #archive_dir instead
|
data/lib/autobuild/import/git.rb
CHANGED
|
@@ -45,6 +45,7 @@ module Autobuild
|
|
|
45
45
|
def initialize(repository, branch = nil, options = {})
|
|
46
46
|
@repository = repository.to_str
|
|
47
47
|
@alternates = Git.default_alternates.dup
|
|
48
|
+
@git_dir_cache = Array.new
|
|
48
49
|
|
|
49
50
|
if branch.respond_to?(:to_hash)
|
|
50
51
|
options = branch.to_hash
|
|
@@ -177,8 +178,44 @@ module Autobuild
|
|
|
177
178
|
# Raises ConfigException if the current directory is not a git
|
|
178
179
|
# repository
|
|
179
180
|
def validate_importdir(package)
|
|
180
|
-
|
|
181
|
-
|
|
181
|
+
return git_dir(package, true)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Resolves the git directory associated with path, and tells whether it
|
|
185
|
+
# is a bare repository or not
|
|
186
|
+
#
|
|
187
|
+
# @param [String] path the path from which we should resolve
|
|
188
|
+
# @return [(String,Symbol),nil] either the path to the git folder and
|
|
189
|
+
# :bare or :normal, or nil if path is not a git repository.
|
|
190
|
+
def self.resolve_git_dir(path)
|
|
191
|
+
dir = File.join(path, '.git')
|
|
192
|
+
if !File.exists?(dir)
|
|
193
|
+
dir = path
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
result = `#{Autobuild.tool(:git)} --git-dir="#{dir}" rev-parse --is-bare-repository`
|
|
197
|
+
if $?.success?
|
|
198
|
+
if result.strip == "true"
|
|
199
|
+
return dir, :bare
|
|
200
|
+
else return dir, :normal
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def git_dir(package, require_working_copy)
|
|
206
|
+
if @git_dir_cache[0] == package.importdir
|
|
207
|
+
dir, style = *@git_dir_cache[1, 2]
|
|
208
|
+
else
|
|
209
|
+
dir, style = Git.resolve_git_dir(package.importdir)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
@git_dir_cache = [package.importdir, dir, style]
|
|
213
|
+
if !style
|
|
214
|
+
raise ConfigException.new(package, 'import'), "while importing #{package.name}, #{package.importdir} does not point to a git repository"
|
|
215
|
+
elsif require_working_copy && (style == :bare)
|
|
216
|
+
raise ConfigException.new(package, 'import'), "while importing #{package.name}, #{package.importdir} points to a bare git repository but a working copy was required"
|
|
217
|
+
else
|
|
218
|
+
return dir
|
|
182
219
|
end
|
|
183
220
|
end
|
|
184
221
|
|
|
@@ -225,7 +262,7 @@ module Autobuild
|
|
|
225
262
|
|
|
226
263
|
# Updates the git repository's configuration for the target remote
|
|
227
264
|
def update_remotes_configuration(package, phase)
|
|
228
|
-
git = [package, phase, Autobuild.tool(:git), '--git-dir',
|
|
265
|
+
git = [package, phase, Autobuild.tool(:git), '--git-dir', git_dir(package, false), 'config', '--replace-all']
|
|
229
266
|
Subprocess.run(*git, "remote.#{remote_name}.url", repository)
|
|
230
267
|
if push_to
|
|
231
268
|
Subprocess.run(*git, "remote.#{remote_name}.pushurl", push_to)
|
|
@@ -249,7 +286,8 @@ module Autobuild
|
|
|
249
286
|
# package's source directory.
|
|
250
287
|
def fetch_remote(package)
|
|
251
288
|
validate_importdir(package)
|
|
252
|
-
|
|
289
|
+
git_dir = git_dir(package, false)
|
|
290
|
+
git = [package, :import, Autobuild.tool('git'), '--git-dir', git_dir]
|
|
253
291
|
|
|
254
292
|
# If we are checking out a specific commit, we don't know which
|
|
255
293
|
# branch to refer to in git fetch. So, we have to set up the
|
|
@@ -268,8 +306,8 @@ module Autobuild
|
|
|
268
306
|
|
|
269
307
|
# Now get the actual commit ID from the FETCH_HEAD file, and
|
|
270
308
|
# return it
|
|
271
|
-
commit_id = if File.readable?( File.join(
|
|
272
|
-
fetch_commit = File.readlines( File.join(
|
|
309
|
+
commit_id = if File.readable?( File.join(git_dir, 'FETCH_HEAD') )
|
|
310
|
+
fetch_commit = File.readlines( File.join(git_dir, 'FETCH_HEAD') ).
|
|
273
311
|
delete_if { |l| l =~ /not-for-merge/ }
|
|
274
312
|
if !fetch_commit.empty?
|
|
275
313
|
fetch_commit.first.split(/\s+/).first
|
|
@@ -429,7 +467,7 @@ module Autobuild
|
|
|
429
467
|
# @param [Package] package the already checked-out package
|
|
430
468
|
# @return [void]
|
|
431
469
|
def update_alternates(package)
|
|
432
|
-
alternates_path = File.join(package
|
|
470
|
+
alternates_path = File.join(git_dir(package, false), 'objects', 'info', 'alternates')
|
|
433
471
|
current_alternates =
|
|
434
472
|
if File.file?(alternates_path)
|
|
435
473
|
File.readlines(alternates_path).map(&:strip).find_all { |l| !l.empty? }
|
|
@@ -583,7 +621,8 @@ module Autobuild
|
|
|
583
621
|
|
|
584
622
|
# Tests whether the given directory is a git repository
|
|
585
623
|
def self.can_handle?(path)
|
|
586
|
-
|
|
624
|
+
_, style = Git.resolve_git_dir(path)
|
|
625
|
+
style == :normal
|
|
587
626
|
end
|
|
588
627
|
|
|
589
628
|
# Returns a hash that represents the configuration of a git importer
|
|
@@ -592,7 +631,7 @@ module Autobuild
|
|
|
592
631
|
# @raise [ArgumentError] if the path does not point to a git repository
|
|
593
632
|
def self.vcs_definition_for(path)
|
|
594
633
|
if !can_handle?(path)
|
|
595
|
-
raise ArgumentError, "#{path} is not a git repository"
|
|
634
|
+
raise ArgumentError, "#{path} is either not a git repository, or a bare git repository"
|
|
596
635
|
end
|
|
597
636
|
|
|
598
637
|
Dir.chdir(path) do
|
data/lib/autobuild/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: autobuild
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.7.11.
|
|
4
|
+
version: 1.7.11.rc2
|
|
5
5
|
prerelease: 7
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2014-05-
|
|
12
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|