github/actions: fix annotation title handling
We currently generate invalid workflow commands when we create annotations with a `title` but no `file`. Let's fix that. While we're here, let's improve handling of `title`s with `:`s. We cannot use `title`s with `::` since GitHub Actions uses this as a separator for different fields between a workflow command. Let's also make sure `metadata` never ends in a `:` to avoid confusing the GitHub Actions command parser about where the `::` separator is meant to be.
This commit is contained in:
parent
170a7ea56e
commit
54383d1c5f
@ -81,6 +81,7 @@ module GitHub
|
||||
}
|
||||
def initialize(type, message, file: nil, title: nil, line: nil, end_line: nil, column: nil, end_column: nil)
|
||||
raise ArgumentError, "Unsupported type: #{type.inspect}" if ANNOTATION_TYPES.exclude?(type)
|
||||
raise ArgumentError, "`title` must not contain `::`" if title.present? && title.include?("::")
|
||||
|
||||
require "utils/tty"
|
||||
@type = type
|
||||
@ -110,7 +111,11 @@ module GitHub
|
||||
end
|
||||
end
|
||||
|
||||
metadata << ",title=#{Actions.escape(@title)}" if @title
|
||||
if @title
|
||||
metadata << (@file ? "," : " ")
|
||||
metadata << "title=#{Actions.escape(@title)}"
|
||||
end
|
||||
metadata << " " if metadata.end_with?(":")
|
||||
|
||||
"::#{metadata}::#{Actions.escape(@message)}"
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user