From 2478e67d16395fbd1a94cfd5d7754375bc764f7f Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Tue, 1 Dec 2020 13:29:30 +0100 Subject: [PATCH 1/2] Switch to date based versioning scheme Since no new tags are created for releases the version has been frozen for some time, with only the commit hash changing. Versions based on the latest commit date make it much easier to identify them. --- src/invidious.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/invidious.cr b/src/invidious.cr index 9c3dffb2..4793a60a 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -64,7 +64,7 @@ HTTP_CHUNK_SIZE = 10485760 # ~10MB CURRENT_BRANCH = {{ "#{`git branch | sed -n '/* /s///p'`.strip}" }} CURRENT_COMMIT = {{ "#{`git rev-list HEAD --max-count=1 --abbrev-commit`.strip}" }} -CURRENT_VERSION = {{ "#{`git describe --tags --abbrev=0`.strip}" }} +CURRENT_VERSION = {{ "#{`git log -1 --format=%cs | sed s/-/./g`.strip}" }} # This is used to determine the `?v=` on the end of file URLs (for cache busting). We # only need to expire modified assets, so we can use this to find the last commit that changes From b409cdece5d4cc3e4f19235c117fb0f39f5a3c16 Mon Sep 17 00:00:00 2001 From: saltycrys <73420320+saltycrys@users.noreply.github.com> Date: Tue, 1 Dec 2020 13:41:19 +0100 Subject: [PATCH 2/2] Improve error message 2 Electric Boogaloo The long backtrace has been moved into a `
` HTML element, as suggested by @B0pol. To make the error still visible it has been added to the top under `Title:`. This also encourages informative issue titles. --- src/invidious/helpers/errors.cr | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 68f7dd31..4487ff8c 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -10,16 +10,29 @@ macro error_template(*args) error_template_helper(env, config, locale, {{*args}}) end +def github_details(summary : String, content : String) + details = %(\n
) + details += %(\n#{summary}) + details += %(\n

) + details += %(\n \n```\n) + details += content.strip + details += %(\n```) + details += %(\n

) + details += %(\n
) + return HTML.escape(details) +end + def error_template_helper(env : HTTP::Server::Context, config : Config, locale : Hash(String, JSON::Any) | Nil, status_code : Int32, exception : Exception) if exception.is_a?(InfoException) return error_template_helper(env, config, locale, status_code, exception.message || "") end env.response.status_code = status_code - issue_template = %(Date: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`) + issue_template = %(Title: `#{exception.message} (#{exception.class})`) + issue_template += %(\nDate: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`) issue_template += %(\nRoute: `#{env.request.resource}`) issue_template += %(\nVersion: `#{SOFTWARE["version"]} @ #{SOFTWARE["branch"]}`) - # issue_template += %(\nPreferences: ```#{env.get("preferences").as(Preferences).to_json}```) - issue_template += %(\nBacktrace: \n```\n#{exception.inspect_with_backtrace}```) + # issue_template += github_details("Preferences", env.get("preferences").as(Preferences).to_pretty_json) + issue_template += github_details("Backtrace", exception.inspect_with_backtrace) error_message = <<-END_HTML Looks like you've found a bug in Invidious. Please open a new issue on GitHub