lib/travis/cli/repo_command.rb in travis-1.8.12.travis.1125.9 vs lib/travis/cli/repo_command.rb in travis-1.8.12.travis.1135.9
- old
+ new
@@ -141,9 +141,24 @@
error "no .travis.yml found" if parent == dir
travis_yaml(parent)
end
end
+ def confirm_and_save_travis_config(confirm = true, file = travis_yaml)
+ if confirm
+ ans = ask [
+ nil,
+ color("Overwrite the config file #{travis_yaml} with the content below?", [:info, :yellow]),
+ color("This reformats the existing file.", [:info, :red]),
+ travis_config.to_yaml,
+ color("(y/N)", [:info, :yellow])
+ ].join("\n\n")
+ confirm = ans =~ /^y/i
+ end
+
+ save_travis_config if confirm
+ end
+
def save_travis_config(file = travis_yaml)
yaml = travis_config.to_yaml
yaml.gsub! /^(\s+)('on'|true):/, "\\1on:"
yaml.gsub! /\A---\s*\n/, ''
File.write(file, yaml)