Class: Braid::Commands::UpgradeConfig
Instance Method Summary
collapse
#config, #force?, handle_error, msg, #msg, run, #verbose?
Methods included from T::Sig
#sig
#git, #git_cache
Instance Method Details
#config_mode ⇒ Object
5
6
7
|
# File 'lib/braid/commands/upgrade_config.rb', line 5
def config_mode
Config::MODE_UPGRADE
end
|
#run(options) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/braid/commands/upgrade_config.rb', line 9
def run(options)
if !config.config_existed
puts <<-MSG
Your repository has no Braid configuration file. It will be created with the
current configuration version when you add the first mirror.
MSG
return
elsif config.config_version == Config::CURRENT_CONFIG_VERSION
puts <<-MSG
Your configuration file is already at the current configuration version (#{Config::CURRENT_CONFIG_VERSION}).
MSG
return
end
puts <<-MSG
Your configuration file will be upgraded from configuration version #{config.config_version} to #{Config::CURRENT_CONFIG_VERSION}.
Other developers on your project will need to use a Braid version compatible
with configuration version #{Config::CURRENT_CONFIG_VERSION}; see
https://cristibalan.github.io/braid/config_versions.html .
MSG
unless config.breaking_change_descs.empty?
puts <<-MSG
The following breaking changes will occur:
#{config.breaking_change_descs.join('')}
MSG
end
if options['dry_run']
puts <<-MSG
Run 'braid upgrade-config#{config.breaking_change_descs.empty? ? '' : ' --allow-breaking-changes'}' to perform the upgrade.
MSG
elsif !config.breaking_change_descs.empty? && !options['allow_breaking_changes']
raise BraidError, 'You must pass --allow-breaking-changes to accept the breaking changes.'
else
config.write_db
add_config_file
had_changes = git.commit('Upgrade configuration')
raise InternalError, 'upgrade-config had no changes??' unless had_changes
msg 'Configuration upgrade complete.'
end
end
|