fig 1.27.10 → 2.0.0.pre.alpha.2
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/Changes +186 -1
- data/README.md +1 -1
- data/bin/fig +3 -81
- data/lib/fig/command/action/source_package.rb +1 -1
- data/lib/fig/command/action/version.rb +1 -1
- data/lib/fig/command/action/version_plain.rb +1 -1
- data/lib/fig/command/initialization.rb +1 -0
- data/lib/fig/command/options/parser.rb +1 -0
- data/lib/fig/command/options.rb +26 -1
- data/lib/fig/command/package_applier.rb +1 -1
- data/lib/fig/command.rb +35 -2
- data/lib/fig/figrc.rb +1 -1
- data/lib/fig/grammar/base.rb +7 -5
- data/lib/fig/grammar/v0.rb +22 -20
- data/lib/fig/grammar/v1.rb +5 -3
- data/lib/fig/grammar/v1_base.rb +44 -29
- data/lib/fig/grammar/v2.rb +13 -11
- data/lib/fig/grammar/version.rb +7 -5
- data/lib/fig/grammar/version_identification.rb +5 -3
- data/lib/fig/operating_system.rb +69 -42
- data/lib/fig/package.rb +16 -5
- data/lib/fig/package_descriptor.rb +3 -1
- data/lib/fig/parser.rb +0 -9
- data/lib/fig/protocol/http.rb +2 -0
- data/lib/fig/protocol.rb +1 -1
- data/lib/fig/repository.rb +1 -2
- data/lib/fig/repository_package_publisher.rb +2 -2
- data/lib/fig/runtime_environment.rb +37 -13
- data/lib/fig/update_lock.rb +1 -1
- data/lib/fig/version.rb +5 -0
- data/lib/fig/working_directory_maintainer.rb +24 -8
- data/lib/fig.rb +4 -4
- data/lib/git_helper.rb +17 -0
- metadata +144 -76
data/lib/fig/protocol/http.rb
CHANGED
data/lib/fig/protocol.rb
CHANGED
data/lib/fig/repository.rb
CHANGED
@@ -5,7 +5,6 @@ require 'set'
|
|
5
5
|
require 'socket'
|
6
6
|
require 'tmpdir'
|
7
7
|
|
8
|
-
require 'fig'
|
9
8
|
require 'fig/at_exit'
|
10
9
|
require 'fig/file_not_found_error'
|
11
10
|
require 'fig/logging'
|
@@ -354,7 +353,7 @@ class Fig::Repository
|
|
354
353
|
FileUtils.mv temporary_package, package_directory
|
355
354
|
|
356
355
|
runtime_directory = package.runtime_directory
|
357
|
-
if File.
|
356
|
+
if File.exist? temporary_runtime
|
358
357
|
FileUtils.mkdir_p File.dirname(runtime_directory)
|
359
358
|
FileUtils.mv temporary_runtime, runtime_directory
|
360
359
|
else
|
@@ -6,7 +6,7 @@ require 'set'
|
|
6
6
|
require 'socket'
|
7
7
|
require 'tmpdir'
|
8
8
|
|
9
|
-
require 'fig'
|
9
|
+
require 'fig/version'
|
10
10
|
require 'fig/at_exit'
|
11
11
|
require 'fig/external_program'
|
12
12
|
require 'fig/file_not_found_error'
|
@@ -671,7 +671,7 @@ class Fig::RepositoryPackagePublisher
|
|
671
671
|
expansion_happened = true; published_package.runtime_directory
|
672
672
|
}
|
673
673
|
|
674
|
-
if expansion_happened && ! File.
|
674
|
+
if expansion_happened && ! File.exist?(expanded_value) && ! File.symlink?(expanded_value)
|
675
675
|
Fig::Logging.warn(
|
676
676
|
%Q<The #{statement.name} variable points to a path that does not exist (#{expanded_value}); retrieve statements that are active when this package is included may fail.>
|
677
677
|
)
|
@@ -58,7 +58,7 @@ class Fig::RuntimeEnvironment
|
|
58
58
|
name = retrieve_statement.variable
|
59
59
|
if @retrieves.has_key?(name)
|
60
60
|
Fig::Logging.warn \
|
61
|
-
%Q<About to overwrite "#{name}" retrieve path of "#{@retrieves[name].
|
61
|
+
%Q<About to overwrite "#{name}" retrieve path of "#{@retrieves[name].tokenized_path.to_escaped_string}" with "#{retrieve_statement.tokenized_path.to_escaped_string}".>
|
62
62
|
end
|
63
63
|
|
64
64
|
@retrieves[name] = retrieve_statement
|
@@ -89,13 +89,13 @@ class Fig::RuntimeEnvironment
|
|
89
89
|
return @named_packages[name]
|
90
90
|
end
|
91
91
|
|
92
|
-
def apply_config(package, config_name, backtrace)
|
92
|
+
def apply_config(package, config_name, backtrace, current_package_depth = 0)
|
93
93
|
if package.applied_config_names.member?(config_name)
|
94
94
|
return
|
95
95
|
end
|
96
96
|
|
97
97
|
Fig::Logging.debug(
|
98
|
-
"Applying #{package.to_descriptive_string_with_config config_name}."
|
98
|
+
"Applying #{package.to_descriptive_string_with_config config_name}, package depth #{current_package_depth}."
|
99
99
|
)
|
100
100
|
|
101
101
|
new_backtrace = backtrace ||
|
@@ -120,7 +120,7 @@ class Fig::RuntimeEnvironment
|
|
120
120
|
package.add_applied_config_name(config_name)
|
121
121
|
config.statements.each do
|
122
122
|
|statement|
|
123
|
-
apply_config_statement(package, statement, new_backtrace)
|
123
|
+
apply_config_statement(package, statement, new_backtrace, current_package_depth)
|
124
124
|
end
|
125
125
|
|
126
126
|
return
|
@@ -161,16 +161,16 @@ class Fig::RuntimeEnvironment
|
|
161
161
|
# In order for this to work correctly, any Overrides need to be processed
|
162
162
|
# before any other kind of Statement. The Statement::Configuration class
|
163
163
|
# guarantees that those come first in its set of Statements.
|
164
|
-
def apply_config_statement(package, statement, backtrace)
|
164
|
+
def apply_config_statement(package, statement, backtrace, current_package_depth)
|
165
165
|
case statement
|
166
166
|
when Fig::Statement::Path
|
167
167
|
prepend_variable(package, statement, backtrace)
|
168
168
|
when Fig::Statement::Set
|
169
169
|
set_variable(package, statement, backtrace)
|
170
170
|
when Fig::Statement::Include
|
171
|
-
include_config(package, statement, backtrace)
|
171
|
+
include_config(package, statement, backtrace, current_package_depth)
|
172
172
|
when Fig::Statement::IncludeFile
|
173
|
-
include_file_config(package, statement, backtrace)
|
173
|
+
include_file_config(package, statement, backtrace, current_package_depth)
|
174
174
|
when Fig::Statement::Override
|
175
175
|
backtrace.add_override(statement)
|
176
176
|
end
|
@@ -195,7 +195,9 @@ class Fig::RuntimeEnvironment
|
|
195
195
|
|
196
196
|
private
|
197
197
|
|
198
|
-
def include_config(
|
198
|
+
def include_config(
|
199
|
+
starting_package, include_statement, backtrace, current_package_depth
|
200
|
+
)
|
199
201
|
# Because package application starts with the synthetic package for the
|
200
202
|
# command-line, we can't really disable includes, full stop. Instead, we
|
201
203
|
# use the fact that the synthetic package hands the Statement::Include the
|
@@ -211,10 +213,19 @@ class Fig::RuntimeEnvironment
|
|
211
213
|
&& package != starting_package \
|
212
214
|
&& package != include_statement.included_package
|
213
215
|
|
216
|
+
if package != starting_package
|
217
|
+
next_package_depth = current_package_depth + 1
|
218
|
+
|
219
|
+
return if @suppress_includes.is_a? Integer and next_package_depth > @suppress_includes
|
220
|
+
else
|
221
|
+
next_package_depth = current_package_depth
|
222
|
+
end
|
223
|
+
|
214
224
|
apply_config(
|
215
225
|
package,
|
216
226
|
resolved_descriptor.config || Fig::Package::DEFAULT_CONFIG,
|
217
|
-
new_backtrace
|
227
|
+
new_backtrace,
|
228
|
+
next_package_depth,
|
218
229
|
)
|
219
230
|
|
220
231
|
return
|
@@ -261,8 +272,10 @@ class Fig::RuntimeEnvironment
|
|
261
272
|
return package, resolved_descriptor, new_backtrace
|
262
273
|
end
|
263
274
|
|
264
|
-
def include_file_config(
|
265
|
-
|
275
|
+
def include_file_config(
|
276
|
+
including_package, include_file_statement, backtrace, current_package_depth
|
277
|
+
)
|
278
|
+
return if @suppress_includes.is_a? Symbol
|
266
279
|
|
267
280
|
full_path = include_file_statement.full_path_relative_to including_package
|
268
281
|
|
@@ -273,8 +286,19 @@ class Fig::RuntimeEnvironment
|
|
273
286
|
package = package_for_file(including_package, full_path, backtrace)
|
274
287
|
config_name = include_file_statement.config_name
|
275
288
|
|
289
|
+
if package != including_package
|
290
|
+
next_package_depth = current_package_depth + 1
|
291
|
+
|
292
|
+
return if @suppress_includes and next_package_depth > @suppress_includes
|
293
|
+
else
|
294
|
+
next_package_depth = current_package_depth
|
295
|
+
end
|
296
|
+
|
276
297
|
apply_config(
|
277
|
-
package,
|
298
|
+
package,
|
299
|
+
config_name || Fig::Package::DEFAULT_CONFIG,
|
300
|
+
new_backtrace,
|
301
|
+
next_package_depth,
|
278
302
|
)
|
279
303
|
|
280
304
|
return
|
@@ -479,7 +503,7 @@ class Fig::RuntimeEnvironment
|
|
479
503
|
def check_source_existence(
|
480
504
|
variable_name, variable_value, package, backtrace
|
481
505
|
)
|
482
|
-
return if File.
|
506
|
+
return if File.exist?(variable_value) || File.symlink?(variable_value)
|
483
507
|
|
484
508
|
raise_repository_error(
|
485
509
|
%Q<In #{package}, the #{variable_name} variable points to a path that does not exist ("#{variable_value}", after expansion).>,
|
data/lib/fig/update_lock.rb
CHANGED
@@ -63,7 +63,7 @@ class Fig::UpdateLock
|
|
63
63
|
|
64
64
|
# Yes, there's a race condition here, but with the way Windows file locking
|
65
65
|
# works, it's better than a boot to the head.
|
66
|
-
if ! File.
|
66
|
+
if ! File.exist? lock_file
|
67
67
|
created_file = File.new(lock_file, 'w')
|
68
68
|
created_file.close
|
69
69
|
end
|
data/lib/fig/version.rb
ADDED
@@ -4,12 +4,12 @@ require 'set'
|
|
4
4
|
|
5
5
|
require 'fig/logging'
|
6
6
|
require 'fig/logging/colorizable'
|
7
|
+
require 'fig/operating_system'
|
7
8
|
require 'fig/package_descriptor'
|
8
9
|
require 'fig/repository_error'
|
9
|
-
require 'fig/working_directory_metadata'
|
10
10
|
require 'fig/user_input_error'
|
11
|
+
require 'fig/working_directory_metadata'
|
11
12
|
|
12
|
-
module Fig; end
|
13
13
|
|
14
14
|
# Copies files from the project directories in FIG_HOME to the user's working
|
15
15
|
# directory. It keeps track of which files have already been copied, and which
|
@@ -17,8 +17,9 @@ module Fig; end
|
|
17
17
|
# that we never have files from two different versions of the same package in
|
18
18
|
# the user's working directory.
|
19
19
|
class Fig::WorkingDirectoryMaintainer
|
20
|
-
def initialize(base_dir)
|
21
|
-
@base_dir
|
20
|
+
def initialize(base_dir, usec_mtime_comparisons)
|
21
|
+
@base_dir = base_dir
|
22
|
+
@usec_mtime_comparisons = usec_mtime_comparisons
|
22
23
|
@package_metadata_by_name = {}
|
23
24
|
@local_fig_data_directory = File.join(@base_dir, '.fig')
|
24
25
|
|
@@ -217,17 +218,17 @@ class Fig::WorkingDirectoryMaintainer
|
|
217
218
|
end
|
218
219
|
FileUtils.mkdir_p(File.dirname(target))
|
219
220
|
|
221
|
+
is_symlink = File.symlink?(source)
|
222
|
+
|
220
223
|
# If the source is a dangling symlink, then there's no time, etc. to
|
221
224
|
# preserve.
|
222
|
-
preserve = File.exist?(source) && !
|
225
|
+
preserve = File.exist?(source) && ! is_symlink
|
223
226
|
|
224
227
|
if File.exist?(target)
|
225
228
|
Fig::Logging.info("Overwriting #{target}.")
|
226
229
|
end
|
227
230
|
|
228
|
-
FileUtils.copy_entry
|
229
|
-
source, target, preserve, false, :remove_destination
|
230
|
-
)
|
231
|
+
FileUtils.copy_entry source, target, preserve, false, :remove_destination
|
231
232
|
end
|
232
233
|
|
233
234
|
if @package_meta
|
@@ -251,6 +252,21 @@ class Fig::WorkingDirectoryMaintainer
|
|
251
252
|
end
|
252
253
|
|
253
254
|
return true if ! File.exist?(target)
|
255
|
+
|
256
|
+
return true if File.size(source) != File.size(target)
|
257
|
+
|
258
|
+
if @usec_mtime_comparisons
|
259
|
+
source_time = File.mtime(source)
|
260
|
+
target_time = File.mtime(target)
|
261
|
+
|
262
|
+
return true if source_time.to_i > target_time.to_i
|
263
|
+
|
264
|
+
source_subsecond = source_time.nsec / 1000
|
265
|
+
target_subsecond = target_time.nsec / 1000
|
266
|
+
|
267
|
+
return source_subsecond > target_subsecond
|
268
|
+
end
|
269
|
+
|
254
270
|
return File.mtime(source) > File.mtime(target)
|
255
271
|
end
|
256
272
|
|
data/lib/fig.rb
CHANGED
data/lib/git_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# TODO spec test for this
|
2
|
+
|
3
|
+
module GitHelper
|
4
|
+
def self.sha1(commitish = 'HEAD', opts = [ '--short '])
|
5
|
+
sha = `git rev-parse #{opts.join(' ')} #{commitish}`.chomp
|
6
|
+
|
7
|
+
# add "-dirty" if commitish is 'HEAD' and the workspace has changes
|
8
|
+
sha += '-dirty' if commitish == 'HEAD' && self.dirty?
|
9
|
+
|
10
|
+
sha.empty? ? nil : sha
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.dirty?
|
14
|
+
changes = `git status --porcelain -uno`
|
15
|
+
!changes.empty?
|
16
|
+
end
|
17
|
+
end
|