lib/tetra/ui/subcommand.rb in tetra-0.49.0 vs lib/tetra/ui/subcommand.rb in tetra-0.50.0

- old
+ new

@@ -43,26 +43,35 @@ log.level = ::Logger::DEBUG if args.delete "--very-very-verbose" @options = args end - # prints an error message and exits unless there is a dry-run in progress + # prints an error message and exits unless a dry-running + # condition is met. Conditions can be: :is_in_progress, :is_not_in_progress + # or :has_finished def ensure_dry_running(state, project) - if project.dry_running? == state + dry_running = project.dry_running? + has_finished = !project.version.nil? + + if (state == :is_in_progress && dry_running) || + (state == :is_not_in_progress && !dry_running) || + (state == :has_finished && !dry_running && has_finished) yield else - if state == true + if (state == :is_in_progress) || + (state == :has_finished && !dry_running && !has_finished) puts "Please start a dry-run first, use \"tetra dry-run start\"" - else + elsif (state == :is_not_in_progress) || + (state == :has_finished && dry_running) puts "Please finish or abort this dry-run first, use \"tetra dry-run finish\" or \"tetra dry-run abort\"" end end end # outputs output of a file generation def print_generation_result(project, result_path, conflict_count = 0) puts "#{format_path(result_path, project)} generated" - puts "Warning: #{conflict_count} unresolved conflicts" if conflict_count > 0 + puts "Warning: #{conflict_count} unresolved conflicts, please review and commit" if conflict_count > 0 end # generates a version of path relative to the current directory def format_path(path, project) full_path = (