From bd6c96e9d14482d523c5b63cbfbe57252dfbaac3 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 5 Dec 2016 09:55:40 -0800 Subject: [PATCH 1/3] github comment_character_limit --- lib/thumbs/pull_request_worker.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/thumbs/pull_request_worker.rb b/lib/thumbs/pull_request_worker.rb index 37a65d4..873a70a 100644 --- a/lib/thumbs/pull_request_worker.rb +++ b/lib/thumbs/pull_request_worker.rb @@ -702,7 +702,7 @@ def create_build_status_comment <%= status[:command] %> -<%= status[:output] %> +<%= status[:output].slice!(0,10000) %> ``` @@ -719,6 +719,7 @@ def create_build_status_comment comment_message = compose_build_status_comment_title(:completed) comment_message << "\n#{@status_title}" comment_message << build_comment + comment_message.slice!(0,65000) update_pull_request_comment(comment_id, comment_message) end From c002f3a2ddc8d2bbb25b5be4c0a961209d8565d7 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 5 Dec 2016 10:05:53 -0800 Subject: [PATCH 2/3] show last characters instead of first --- lib/thumbs/pull_request_worker.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/thumbs/pull_request_worker.rb b/lib/thumbs/pull_request_worker.rb index 873a70a..5194d5a 100644 --- a/lib/thumbs/pull_request_worker.rb +++ b/lib/thumbs/pull_request_worker.rb @@ -702,7 +702,10 @@ def create_build_status_comment <%= status[:command] %> -<%= status[:output].slice!(0,10000) %> +<% output=status[:output] %> +<% allowed_length=10000 %> +<%= output.slice!(output.length-allowed_length, output.length) %> + ``` @@ -719,8 +722,11 @@ def create_build_status_comment comment_message = compose_build_status_comment_title(:completed) comment_message << "\n#{@status_title}" comment_message << build_comment - comment_message.slice!(0,65000) - update_pull_request_comment(comment_id, comment_message) + if comment_message.length > 65000 + debug_message "comment_message too large : #{comment_message.length} unable to post" + else + update_pull_request_comment(comment_id, comment_message) + end end def render_reviewers_comment_template From be633c6505cfbddad3de3142dc3da8192bea7334 Mon Sep 17 00:00:00 2001 From: David Andersen Date: Mon, 5 Dec 2016 10:38:51 -0800 Subject: [PATCH 3/3] show snipped lines --- lib/thumbs/pull_request_worker.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/thumbs/pull_request_worker.rb b/lib/thumbs/pull_request_worker.rb index 5194d5a..d4be905 100644 --- a/lib/thumbs/pull_request_worker.rb +++ b/lib/thumbs/pull_request_worker.rb @@ -704,7 +704,14 @@ def create_build_status_comment <% output=status[:output] %> <% allowed_length=10000 %> -<%= output.slice!(output.length-allowed_length, output.length) %> +<% if output.length > allowed_length %> + <% snipped_characters = output.length - allowed_length %> + <% snipped_lines = output.slice(0, output.length-allowed_length).split(/\n/) %> +... Snipped <%= snipped_lines.length %> lines ... +<%= output.slice(output.length-allowed_length, output.length) %> +<% else %> + <%= output %> +<% end %> ```