Class: KnifeTable::TableOrder
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- KnifeTable::TableOrder
- Includes:
- Helpers
- Defined in:
- lib/chef/knife/table_order.rb
Instance Method Summary collapse
Methods included from Helpers
#cookbook_path, #discover_changed, #git
Instance Method Details
#run ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/chef/knife/table_order.rb', line 44 def run ui.msg ui.highline.color("#{' ' * 10}** Knife Table: Placing Order **", [HighLine::GREEN, HighLine::BOLD]) if(config[:foodcritic]) fail_on = Array(config[:foodcritic_fail_on]).map{|s| "-f #{s}"}.join(' ') cookbooks = discover_changed(:cookbooks, 'master', 'HEAD').map{|c| c.split('/').first} pass = true cookbooks.each do |cookbook| res = system("foodcritic #{fail_on} #{File.join(cookbook_path, cookbook)}") pass = res unless res end unless(pass) ui.fatal "Modifications do not currently pass foodcritic!" exit 1 end end # TODO: Update this to not shell out cmd = "hub pull-request \"#{title}\" -b #{@upstream}:#{config[:upstream_branch]} -h #{local_user}:#{local_branch}" output = '' err = nil unless(File.exists?(File.join(ENV['HOME'], '.config', 'hub'))) g_config = Hub::GitHubAPI::Configuration.new(nil) g_user = g_config.prompt 'Github username' g_pass = g_config.prompt_password 'Github', g_user end res = Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| if(g_user) stdin.puts g_user stdin.puts g_pass end output << stdout.readlines.last.to_s err = stderr.readlines.last.to_s wait_thr.value end output.strip! if(res.success?) ui.msg "New pull request: #{output}" else ui.error err.to_s.empty? ? 'Failed to create pull request' : err end end |