fig 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Changes CHANGED
@@ -1,3 +1,49 @@
1
+ v1.3.0
2
+
3
+ Backwards incompatibility:
4
+
5
+ - If you specify one of FIG_USERNAME/FIG_PASSWORD, you must specify both.
6
+
7
+ Bug fixes:
8
+
9
+ - In the change to not use the environment variables/prompting for assets,
10
+ ~/.netrc gained priority over the environment variables again. Fixed.
11
+
12
+ - Newlines are allowed in command-line options.
13
+
14
+ New feature:
15
+
16
+ - New --publish-comment option that allows you to put a comment at the top of
17
+ published packages. Works regardless of whether the package definition
18
+ comes from a file or other command-line options.
19
+
20
+ > fig --publish package/version --publish-comment $'This package is\n awesome!' ...
21
+
22
+ > fig --dump-package-definition-text package/version
23
+ # This package is
24
+ # awesome!
25
+ #
26
+ #
27
+ # Publishing information for package/version:
28
+ ...
29
+
30
+ Miscellaneous:
31
+
32
+ - Publishing now includes VCS revision information.
33
+
34
+ For Subversion, this is from the "Revision: " in the output of "svn info".
35
+ It might be better to use the output of "svnversion", but this would
36
+ require an additional FIG_SVNVERSION_EXECUTABLE environment variable and it
37
+ seems better to keep things simpler by avoiding that.
38
+
39
+ For Git, it includes the current branch and SHA1.
40
+
41
+ v1.2.1.beta.3
42
+ v1.2.1.beta.2
43
+ v1.2.1.beta.1
44
+
45
+ - Test releases.
46
+
1
47
  v1.2.0
2
48
 
3
49
  Bug fixes:
data/lib/fig.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fig
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -60,6 +60,7 @@ class Fig::Command::Options
60
60
  attr_reader :log_level
61
61
  attr_reader :package_definition_file
62
62
  attr_reader :parser
63
+ attr_reader :publish_comment
63
64
  attr_reader :shell_command
64
65
  attr_reader :suppress_cleanup_of_retrieves
65
66
  attr_reader :suppress_includes
@@ -164,7 +165,7 @@ class Fig::Command::Options
164
165
  # Note that OptionParser insists that the regex match the entire value, not
165
166
  # just matches the regex in general. In effect, OptionParser is wrapping the
166
167
  # regex with "\A" and "\z".
167
- STARTS_WITH_NON_HYPHEN = %r< \A [^-] .* >x
168
+ STARTS_WITH_NON_HYPHEN = %r< \A [^-] .* >xm
168
169
 
169
170
  def list_all_configs?()
170
171
  return @list_all_configs
@@ -362,6 +363,14 @@ class Fig::Command::Options
362
363
  set_base_action(Fig::Command::Action::PublishLocal)
363
364
  end
364
365
 
366
+ @parser.on(
367
+ '--publish-comment COMMENT',
368
+ STARTS_WITH_NON_HYPHEN,
369
+ 'comment to include in published package'
370
+ ) do |comment|
371
+ @publish_comment = comment
372
+ end
373
+
365
374
  @force = nil
366
375
  @parser.on(
367
376
  '--force',
@@ -754,16 +763,18 @@ class Fig::Command::Options
754
763
  raise Fig::Command::OptionError.new(
755
764
  'Cannot use --suppress-all-includes/--suppress-cross-package-includes with --list-all-configs.'
756
765
  )
757
- elsif @base_action.list_dependencies?
758
- raise Fig::Command::OptionError.new(
759
- %q<It doesn't make much sense to suppress dependencies when attempting to list them.>
760
- )
761
- elsif @base_action.publish?
762
- # Don't want to support broken publishes (though versionless includes
763
- # are pretty broken).
764
- raise Fig::Command::OptionError.new(
765
- 'Cannot use --suppress-all-includes/--suppress-cross-package-includes when publishing.'
766
- )
766
+ elsif @base_action
767
+ if @base_action.list_dependencies?
768
+ raise Fig::Command::OptionError.new(
769
+ %q<It doesn't make much sense to suppress dependencies when attempting to list them.>
770
+ )
771
+ elsif @base_action.publish?
772
+ # Don't want to support broken publishes (though versionless includes
773
+ # are pretty broken).
774
+ raise Fig::Command::OptionError.new(
775
+ 'Cannot use --suppress-all-includes/--suppress-cross-package-includes when publishing.'
776
+ )
777
+ end
767
778
  end
768
779
  elsif list_tree?
769
780
  validate_list_option '--list-tree'
@@ -779,6 +790,12 @@ class Fig::Command::Options
779
790
  )
780
791
  end
781
792
 
793
+ if @publish_comment && (! @base_action || ! @base_action.publish?)
794
+ raise Fig::Command::OptionError.new(
795
+ 'Cannot use --publish-comment when not publishing.'
796
+ )
797
+ end
798
+
782
799
  return
783
800
  end
784
801
 
@@ -244,9 +244,9 @@ class Fig::OperatingSystem
244
244
 
245
245
  def shell_exec(command)
246
246
  if Fig::OperatingSystem.windows?
247
- plain_exec [ ENV['ComSpec'], '/c', command ]
247
+ plain_exec [ ENV['ComSpec'], '/c', command ]
248
248
  else
249
- plain_exec [ ENV['SHELL'], '-c', command ]
249
+ plain_exec [ ENV['SHELL'] || '/bin/sh', '-c', command ]
250
250
  end
251
251
  end
252
252
 
@@ -24,15 +24,21 @@ module Fig::Protocol::NetRCEnabled
24
24
  end
25
25
 
26
26
  entry = nil
27
- begin
28
- login_data = Net::Netrc.locate host
29
- if login_data
30
- entry = NetRCEntry.new login_data.login, login_data.password
31
- elsif prompt_if_missing
32
- entry = get_authentication_from_user(host)
27
+ if prompt_if_missing
28
+ entry = get_authentication_from_environment
29
+ end
30
+
31
+ if ! entry
32
+ begin
33
+ login_data = Net::Netrc.locate host
34
+ if login_data
35
+ entry = NetRCEntry.new login_data.login, login_data.password
36
+ elsif prompt_if_missing
37
+ entry = get_authentication_from_user(host)
38
+ end
39
+ rescue SecurityError => error
40
+ raise Fig::UserInputError.new error.message
33
41
  end
34
- rescue SecurityError => error
35
- raise Fig::UserInputError.new error.message
36
42
  end
37
43
 
38
44
  @netrc_entries_by_host[host] = entry
@@ -40,15 +46,31 @@ module Fig::Protocol::NetRCEnabled
40
46
  return entry
41
47
  end
42
48
 
49
+ def get_authentication_from_environment()
50
+ username = ENV['FIG_USERNAME']
51
+ password = ENV['FIG_PASSWORD']
52
+
53
+ if username.nil? && password.nil?
54
+ return nil
55
+ end
56
+
57
+ if ! username.nil? && ! password.nil?
58
+ return NetRCEntry.new username, password
59
+ end
60
+
61
+ if password.nil?
62
+ raise Fig::UserInputError.new \
63
+ 'FIG_USERNAME is set but FIG_PASSWORD is not.'
64
+ end
65
+
66
+ raise Fig::UserInputError.new 'FIG_PASSWORD is set but FIG_USERNAME is not.'
67
+ end
68
+
43
69
  def get_authentication_from_user(host)
44
- username =
45
- ENV['FIG_USERNAME'] ||
46
- HighLine.new.ask("Username for #{host}: ") { |q| q.echo = true }
47
- password =
48
- ENV['FIG_PASSWORD'] ||
49
- HighLine.new.ask("Password for #{username}@#{host}: ") {
50
- |q| q.echo = false
51
- }
70
+ username = HighLine.new.ask("Username for #{host}: ") { |q| q.echo = true }
71
+ password = HighLine.new.ask("Password for #{username}@#{host}: ") {
72
+ |q| q.echo = false
73
+ }
52
74
 
53
75
  return NetRCEntry.new username, password
54
76
  end
@@ -147,6 +147,8 @@ class Fig::RepositoryPackagePublisher
147
147
  end
148
148
 
149
149
  def add_package_metadata_comments()
150
+ add_publish_comment
151
+
150
152
  @text_assembler.add_header(
151
153
  %Q<# Publishing information for #{@descriptor.to_string()}:>
152
154
  )
@@ -158,7 +160,10 @@ class Fig::RepositoryPackagePublisher
158
160
 
159
161
  @text_assembler.add_header %Q<# User: #{@publish_login}>
160
162
  @text_assembler.add_header %Q<# Host: #{@publish_host}>
161
- @text_assembler.add_header %Q<# Args: "#{ARGV.join %q[", "]}">
163
+
164
+ sanitized_argv = ARGV.map {|arg| arg.gsub "\n", '\\n'}
165
+ @text_assembler.add_header %Q<# Args: "#{sanitized_argv.join %q[", "]}">
166
+
162
167
  @text_assembler.add_header %Q<# Fig: v#{Fig::VERSION}>
163
168
 
164
169
  add_environment_variables_to_package_metadata
@@ -169,6 +174,17 @@ class Fig::RepositoryPackagePublisher
169
174
  return
170
175
  end
171
176
 
177
+ def add_publish_comment
178
+ return if ! @options.publish_comment
179
+
180
+ comment = @options.publish_comment.strip.gsub /[ \t]*\n/, "\n# "
181
+ @text_assembler.add_header %Q<# #{comment}>
182
+ @text_assembler.add_header %q<#>
183
+ @text_assembler.add_header %q<#>
184
+
185
+ return
186
+ end
187
+
172
188
  def add_environment_variables_to_package_metadata()
173
189
  variables = @application_configuration[
174
190
  'environment variables to include in comments in published packages'
@@ -197,20 +213,25 @@ class Fig::RepositoryPackagePublisher
197
213
  def add_version_control_to_package_metadata()
198
214
  return if @options.suppress_vcs_comments_in_published_packages?
199
215
 
200
- add_subversion_url_to_package_metadata()
201
- add_git_url_to_package_metadata()
216
+ add_subversion_metadata_to_package_metadata()
217
+ add_git_metadata_to_package_metadata()
202
218
 
203
219
  return
204
220
  end
205
221
 
206
- def add_subversion_url_to_package_metadata()
222
+ def add_subversion_metadata_to_package_metadata()
207
223
  output = get_subversion_working_directory_info
208
224
  return if not output =~ /^URL: +(.*\S)\s*$/
209
225
  url = $1
210
226
 
227
+ revision = ''
228
+ if output =~ /^Revision: +(\S+)\s*$/
229
+ revision = ", revision #{$1}"
230
+ end
231
+
211
232
  @text_assembler.add_header %q<#>
212
233
  @text_assembler.add_header(
213
- %Q<# Publish happened in a Subversion working directory from\n# #{url}.>
234
+ %Q<# Publish happened in a Subversion working directory from\n# #{url}#{revision}.>
214
235
  )
215
236
 
216
237
  return
@@ -255,14 +276,27 @@ class Fig::RepositoryPackagePublisher
255
276
  return executable
256
277
  end
257
278
 
258
- def add_git_url_to_package_metadata()
279
+ def add_git_metadata_to_package_metadata()
259
280
  url = get_git_origin_url or return
260
281
  url.strip!
261
282
  return if url.empty?
262
283
 
284
+ branch = get_git_branch
285
+ if branch.nil?
286
+ branch = ''
287
+ else
288
+ branch = ", branch #{branch}"
289
+ end
290
+ sha1 = get_git_sha1
291
+ if sha1.nil?
292
+ sha1 = ''
293
+ else
294
+ sha1 = ",\n# SHA1 #{sha1}"
295
+ end
296
+
263
297
  @text_assembler.add_header %q<#>
264
298
  @text_assembler.add_header(
265
- %Q<# Publish happened in a Git working directory from\n# #{url}.>
299
+ %Q<# Publish happened in a Git working directory from\n# #{url}#{branch}#{sha1}.>
266
300
  )
267
301
 
268
302
  return
@@ -278,6 +312,36 @@ class Fig::RepositoryPackagePublisher
278
312
  )
279
313
  end
280
314
 
315
+ def get_git_branch()
316
+ executable =
317
+ get_version_control_executable('FIG_GIT_EXECUTABLE', 'git') or return
318
+ reference = run_version_control_command(
319
+ [executable, 'rev-parse', '--abbrev-ref=strict', 'HEAD'],
320
+ 'Git',
321
+ 'FIG_GIT_EXECUTABLE'
322
+ )
323
+ return if reference.nil?
324
+
325
+ reference.strip!
326
+ return if reference.empty?
327
+
328
+ return reference
329
+ end
330
+
331
+ def get_git_sha1()
332
+ executable =
333
+ get_version_control_executable('FIG_GIT_EXECUTABLE', 'git') or return
334
+ reference = run_version_control_command(
335
+ [executable, 'rev-parse', 'HEAD'], 'Git', 'FIG_GIT_EXECUTABLE'
336
+ )
337
+ return if reference.nil?
338
+
339
+ reference.strip!
340
+ return if reference.empty?
341
+
342
+ return reference
343
+ end
344
+
281
345
  # Deals with Archive and Resource statements. It downloads any remote
282
346
  # files (those where the statement references a URL as opposed to a local
283
347
  # file) and then copies all files into the local repository and the remote
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-26 00:00:00.000000000 Z
12
+ date: 2013-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
16
- requirement: &16367000 !ruby/object:Gem::Requirement
16
+ requirement: &7783280 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.5.8
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16367000
24
+ version_requirements: *7783280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: highline
27
- requirement: &16366480 !ruby/object:Gem::Requirement
27
+ requirement: &7782280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.6.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *16366480
35
+ version_requirements: *7782280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &16365980 !ruby/object:Gem::Requirement
38
+ requirement: &7781400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.5
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *16365980
46
+ version_requirements: *7781400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: libarchive-static
49
- requirement: &16365480 !ruby/object:Gem::Requirement
49
+ requirement: &7780440 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *16365480
57
+ version_requirements: *7780440
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: log4r
60
- requirement: &16364880 !ruby/object:Gem::Requirement
60
+ requirement: &7779700 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.1.5
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *16364880
68
+ version_requirements: *7779700
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: net-netrc
71
- requirement: &16364380 !ruby/object:Gem::Requirement
71
+ requirement: &7797340 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.2.2
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *16364380
79
+ version_requirements: *7797340
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: net-sftp
82
- requirement: &16363920 !ruby/object:Gem::Requirement
82
+ requirement: &7796880 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 2.0.4
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *16363920
90
+ version_requirements: *7796880
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: net-ssh
93
- requirement: &16471780 !ruby/object:Gem::Requirement
93
+ requirement: &7796340 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 2.0.15
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *16471780
101
+ version_requirements: *7796340
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: open4
104
- requirement: &16471280 !ruby/object:Gem::Requirement
104
+ requirement: &7795660 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.0.1
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *16471280
112
+ version_requirements: *7795660
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rdoc
115
- requirement: &16470760 !ruby/object:Gem::Requirement
115
+ requirement: &7794460 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '3.12'
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *16470760
123
+ version_requirements: *7794460
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: sys-admin
126
- requirement: &16470220 !ruby/object:Gem::Requirement
126
+ requirement: &7793400 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 1.5.6
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *16470220
134
+ version_requirements: *7793400
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: treetop
137
- requirement: &16469680 !ruby/object:Gem::Requirement
137
+ requirement: &7792720 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: 1.4.2
143
143
  type: :runtime
144
144
  prerelease: false
145
- version_requirements: *16469680
145
+ version_requirements: *7792720
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: bundler
148
- requirement: &16469140 !ruby/object:Gem::Requirement
148
+ requirement: &7792200 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: 1.0.15
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *16469140
156
+ version_requirements: *7792200
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rake
159
- requirement: &16468620 !ruby/object:Gem::Requirement
159
+ requirement: &7791600 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: 0.8.7
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *16468620
167
+ version_requirements: *7791600
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: rspec
170
- requirement: &16468100 !ruby/object:Gem::Requirement
170
+ requirement: &7791100 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ~>
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: '2'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *16468100
178
+ version_requirements: *7791100
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: rspec-core
181
- requirement: &16467580 !ruby/object:Gem::Requirement
181
+ requirement: &7790640 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ! '>='
@@ -186,10 +186,10 @@ dependencies:
186
186
  version: 2.7.1
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *16467580
189
+ version_requirements: *7790640
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: rspec-expectations
192
- requirement: &16467100 !ruby/object:Gem::Requirement
192
+ requirement: &7790180 !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
195
195
  - - ! '>='
@@ -197,10 +197,10 @@ dependencies:
197
197
  version: 2.7.0
198
198
  type: :development
199
199
  prerelease: false
200
- version_requirements: *16467100
200
+ version_requirements: *7790180
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: rspec-mocks
203
- requirement: &16466520 !ruby/object:Gem::Requirement
203
+ requirement: &7789720 !ruby/object:Gem::Requirement
204
204
  none: false
205
205
  requirements:
206
206
  - - ! '>='
@@ -208,10 +208,10 @@ dependencies:
208
208
  version: 2.7.0
209
209
  type: :development
210
210
  prerelease: false
211
- version_requirements: *16466520
211
+ version_requirements: *7789720
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: simplecov
214
- requirement: &16465740 !ruby/object:Gem::Requirement
214
+ requirement: &7871460 !ruby/object:Gem::Requirement
215
215
  none: false
216
216
  requirements:
217
217
  - - ! '>='
@@ -219,10 +219,10 @@ dependencies:
219
219
  version: 0.6.2
220
220
  type: :development
221
221
  prerelease: false
222
- version_requirements: *16465740
222
+ version_requirements: *7871460
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: simplecov-html
225
- requirement: &16465240 !ruby/object:Gem::Requirement
225
+ requirement: &7870980 !ruby/object:Gem::Requirement
226
226
  none: false
227
227
  requirements:
228
228
  - - ! '>='
@@ -230,7 +230,7 @@ dependencies:
230
230
  version: 0.5.3
231
231
  type: :development
232
232
  prerelease: false
233
- version_requirements: *16465240
233
+ version_requirements: *7870980
234
234
  description: Fig is a utility for configuring environments and managing dependencies
235
235
  across a team of developers. Given a list of packages and a command to run, Fig
236
236
  builds environment variables named in those packages (e.g., CLASSPATH), then executes