Skip to content

Commit

Permalink
fix: show git errors (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored May 29, 2023
1 parent 617d19b commit e49f248
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ GUID := $(shell id -g)
CRYSTAL_VERSION := 1.8

build:
shards build coveralls --progress
shards build coveralls --progress --error-trace

test:
crystal spec --order random --error-on-warnings
Expand Down
15 changes: 8 additions & 7 deletions src/coverage_reporter/cli/cmd.cr
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,18 @@ module CoverageReporter::Cli
end

private def greet(no_logo : Bool)
red = Colorize::Color256.new(196)
Colorize.on_tty_only!

if no_logo
Log.info "⭐️ Coveralls.io Coverage Reporter v#{CoverageReporter::VERSION}"
else
Log.info " "
Log.info "⠀⠀⠀⠀⠀⠀#{"".colorize(red)}"
Log.info "⠀⠀⠀⠀⠀#{"⣼⣿⣧".colorize(red)}⠀⠀⠀⠀⠀⠀⠀ ⣠⣶⣾⣿⡇⢀⣴⣾⣿⣷⣆ ⣿⣿⠀⣰⣿⡟⢸⣿⣿⣿⡇ ⣿⣿⣿⣷⣦⠀⠀⢠⣿⣿⣿⠀⠀⣿⣿⠁⠀⣼⣿⡇⠀⢀⣴⣾⣿⡷"
Log.info "#{"⠶⣶⣶⣶⣾⣿⣿⣿⣷⣶⣶⣶⠶".colorize(red)} ⣸⣿⡟ ⠀⢠⣿⣿⠃⠈⣿⣿⠀⣿⣿⢠⣿⡿⠀⣿⣿⣧⣤⠀⢸⣿⡇⣠⣿⡿⠀⢠⣿⡟⣿⣿⠀⢸⣿⡿⠀⠀⣿⣿⠃⠀⢸⣿⣧⣄"
Log.info "⠀⠀#{"⠙⢻⣿⣿⣿⣿⣿⡟⠋⠁".colorize(red)}⠀⠀ ⣿⣿⡇⠀ ⢸⣿⣿⠀⣸⣿⡟⠀⣿⣿⣾⡿⠁ ⣿⣿⠛⠛⠀⣿⣿⢿⣿⣏⠀⢀⣿⣿⣁⣿⣿⠀⣾⣿⡇⠀⢸⣿⡿⠀⠀⡀⠙⣿⣿⡆"
Log.info "⠀⠀#{"⢠⣿⣿⣿⠿⣿⣿⣿⡄".colorize(red)}⠀⠀⠀ ⠙⢿⣿⣿⠇⠈⠿⣿⣿⡿⠋⠀⠀⢿⣿⡿⠁⠀⢸⣿⣿⣿⡇⢸⣿⣿⠀⣿⣿⣄⣾⣿⠛⠛⣿⣿⢠⣿⣿⣿ ⣼⣿⣿⣿ ⣿⣿⡿⠋⠀"
Log.info "#{"⢀⣾⠟⠋⠀⠀⠀⠙⠻⣷⡀".colorize(red)}⠀⠀"
Log.info "⠀⠀⠀⠀⠀⠀#{"".colorize(Log::RED)}"
Log.info "⠀⠀⠀⠀⠀#{"⣼⣿⣧".colorize(Log::RED)}⠀⠀⠀⠀⠀⠀⠀ ⣠⣶⣾⣿⡇⢀⣴⣾⣿⣷⣆ ⣿⣿⠀⣰⣿⡟⢸⣿⣿⣿⡇ ⣿⣿⣿⣷⣦⠀⠀⢠⣿⣿⣿⠀⠀⣿⣿⠁⠀⣼⣿⡇⠀⢀⣴⣾⣿⡷"
Log.info "#{"⠶⣶⣶⣶⣾⣿⣿⣿⣷⣶⣶⣶⠶".colorize(Log::RED)} ⣸⣿⡟ ⠀⢠⣿⣿⠃⠈⣿⣿⠀⣿⣿⢠⣿⡿⠀⣿⣿⣧⣤⠀⢸⣿⡇⣠⣿⡿⠀⢠⣿⡟⣿⣿⠀⢸⣿⡿⠀⠀⣿⣿⠃⠀⢸⣿⣧⣄"
Log.info "⠀⠀#{"⠙⢻⣿⣿⣿⣿⣿⡟⠋⠁".colorize(Log::RED)}⠀⠀ ⣿⣿⡇⠀ ⢸⣿⣿⠀⣸⣿⡟⠀⣿⣿⣾⡿⠁ ⣿⣿⠛⠛⠀⣿⣿⢿⣿⣏⠀⢀⣿⣿⣁⣿⣿⠀⣾⣿⡇⠀⢸⣿⡿⠀⠀⡀⠙⣿⣿⡆"
Log.info "⠀⠀#{"⢠⣿⣿⣿⠿⣿⣿⣿⡄".colorize(Log::RED)}⠀⠀⠀ ⠙⢿⣿⣿⠇⠈⠿⣿⣿⡿⠋⠀⠀⢿⣿⡿⠁⠀⢸⣿⣿⣿⡇⢸⣿⣿⠀⣿⣿⣄⣾⣿⠛⠛⣿⣿⢠⣿⣿⣿ ⣼⣿⣿⣿ ⣿⣿⡿⠋⠀"
Log.info "#{"⢀⣾⠟⠋⠀⠀⠀⠙⠻⣷⡀".colorize(Log::RED)}⠀⠀"
Log.info " "
Log.info " v#{CoverageReporter::VERSION}\n\n"
end
Expand Down
11 changes: 10 additions & 1 deletion src/coverage_reporter/git.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "io"
require "process"
require "colorize"

module CoverageReporter
# General Git information required for Coveralls API.
Expand Down Expand Up @@ -67,8 +68,16 @@ module CoverageReporter
end

protected def command_line(command) : String
err = IO::Memory.new
io = IO::Memory.new
Process.run(command, shell: true, output: io)
ret = Process.run(command, shell: true, output: io, error: err)
unless ret.success?
Log.debug("Error running command:".colorize(Log::YELLOW))
Log.debug
Log.warn("⚠️ #{command} (return code #{ret})")
Log.debug
Log.debug(err.to_s.colorize(Log::YELLOW))
end
io.to_s
end

Expand Down
12 changes: 11 additions & 1 deletion src/coverage_reporter/log.cr
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
require "colorize"

module CoverageReporter
# Console output manager.
module Log
extend self

RED = Colorize::Color256.new(196) # ff0000
YELLOW = Colorize::Color256.new(220) # ffaf00

enum Level
Error
Warning
Info
Debug
end
Expand All @@ -21,8 +27,12 @@ module CoverageReporter
log(Level::Info, STDOUT, *args)
end

def warn(*args)
log(Level::Warning, STDERR, *(args.try(&.map(&.to_s.colorize(YELLOW)))))
end

def error(*args)
log(Level::Error, STDERR, *args)
log(Level::Error, STDERR, *(args.try(&.map(&.to_s.colorize(RED)))))
end

private def log(level, io, *args)
Expand Down
2 changes: 1 addition & 1 deletion src/coverage_reporter/parser.cr
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module CoverageReporter
return parser.parse(filename)
end

Log.info "⚠️ Coverage reporter does not yet know how to process this file: #{filename}"
Log.warn "⚠️ Coverage reporter does not yet know how to process this file: #{filename}"
[] of FileReport
end
end
Expand Down

0 comments on commit e49f248

Please sign in to comment.