Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def truncate_pr_message(msg)
msg = (msg[0..trunc_length] + tr_msg)
end
# if we used a custom encoding for calculating length, then we need to force back to UTF-8
msg.force_encoding(Encoding::UTF_8) unless pr_message_encoding.nil?
msg = msg.encode("utf-8", "binary", invalid: :replace, undef: :replace) unless pr_message_encoding.nil?
msg
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2791,11 +2791,17 @@ def commits_details(base:, head:)
trunc_msg = (+"...\n\n_Description has been truncated_").force_encoding(encode_utf16)
trunc_length = pr_message_max_length - trunc_msg.length
msg = "#{msg[0..trunc_length]}#{trunc_msg}"
msg = msg.force_encoding(Encoding::UTF_8)
msg = msg.encode("utf-8", "binary", invalid: :replace, undef: :replace)

message_builder.pr_message_max_length = pr_message_max_length
message_builder.pr_message_encoding = encode_utf16
expect(message_builder.truncate_pr_message(message)).to eq(msg)

# ensure we can work convert to JSON (uses UTF-8 by default)
# this matches what happens in the azure client when creating a pull request
expect({ description: msg }.to_json)
.to start_with("{\"description\":\"")
.and end_with("\\n\\n_Description has been truncated_\"}")
end
end

Expand Down