Skip to content

Commit

Permalink
annotations: re-apply some fixes.
Browse files Browse the repository at this point in the history
Co-authored-by: Carlo Cabrera <[email protected]>
  • Loading branch information
MikeMcQuaid and carlocab committed Sep 16, 2024
1 parent 1c39009 commit f120d02
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Library/Homebrew/extend/kernel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ def oh1(title, truncate: :auto)
sig { params(message: T.any(String, Exception)).void }
def opoo(message)
Tty.with($stderr) do |stderr|
stderr.puts Formatter.warning(message, label: "Warning")
GitHub::Actions.puts_annotation_if_env_set(:warning, message.to_s)
if GitHub::Actions.env_set?
GitHub::Actions.puts_annotation_if_env_set(:warning, message.to_s)
else
stderr.puts Formatter.warning(message, label: "Warning")
end
end
end

Expand All @@ -79,8 +82,11 @@ def onoe(message)
require "utils/github/actions"

Tty.with($stderr) do |stderr|
stderr.puts Formatter.error(message, label: "Error")
GitHub::Actions.puts_annotation_if_env_set(:error, message.to_s)
if GitHub::Actions.env_set?
GitHub::Actions.puts_annotation_if_env_set(:error, message.to_s)
else
stderr.puts Formatter.error(message, label: "Error")
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/utils/github/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def self.puts_annotation_if_env_set(type, message, file: nil, line: nil)
return unless env_set?

std = (type == :notice) ? $stdout : $stderr
std.puts Annotation.new(type, message)
std.puts Annotation.new(type, message, file:, line:)
end

# Helper class for formatting annotations on GitHub Actions.
Expand Down

0 comments on commit f120d02

Please sign in to comment.