lib/danger/commands/init.rb in danger-0.8.2 vs lib/danger/commands/init.rb in danger-0.8.3

- old
+ new

@@ -5,26 +5,28 @@ module Danger class Init < Runner self.summary = 'Helps you set up Danger.' self.command = 'init' + attr_accessor :ui + def self.options [ ['--impatient', "'I've not got all day here. Don't add any thematic delays please.'"], ['--mousey', "'Don't make me press return to continue the adventure.'"] ].concat(super) end def initialize(argv) - ui.no_delay = argv.flag?('impatient', false) - ui.no_waiting = argv.flag?('mousey', false) @bot_name = File.basename(Dir.getwd).split(".").first.capitalize + "Bot" super + @ui = Interviewer.new(cork) + ui.no_delay = argv.flag?('impatient', false) + ui.no_waiting = argv.flag?('mousey', false) end def run - ui = Interviewer.new ui.say "\nOK, thanks #{ENV['LOGNAME']}, have a seat and we'll get you started.\n".yellow ui.pause 1 show_todo_state ui.pause 1.4 @@ -36,14 +38,10 @@ info thanks end - def ui - @ui ||= Interviewer.new - end - def show_todo_state ui.say "We need to do the following:\n" ui.pause 0.6 ui.say " - [ ] Create a Dangerfile and add a few simple rules." ui.pause 0.6 @@ -132,11 +130,12 @@ def considered_an_oss_repo? @is_open_source == "open" end def current_repo_slug - @repo ||= Danger::CISource::LocalGitRepo.new - @repo.repo_slug || "[Your/Repo]" + @git = GitRepo.new + repo_matches = @git.origins.match(%r{([\/:])([^\/]+\/[^\/.]+)(?:.git)?$}) + repo_matches[2] || "[Your/Repo]" end def setup_danger_ci ui.header 'Step 4: Add Danger for your CI'