Skip to content

Commit

Permalink
Merge pull request #18329 from Homebrew/limit-annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocab authored Sep 15, 2024
2 parents 1f306b4 + c6e2cd9 commit 6c3c513
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 ENV["HOMEBREW_GITHUB_ACTIONS"].present?
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 ENV["HOMEBREW_GITHUB_ACTIONS"].present?
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 6c3c513

Please sign in to comment.