From c174bfa52f5eb6ba5695eea77df73e33ccae5274 Mon Sep 17 00:00:00 2001 From: Enzo Date: Mon, 19 Apr 2021 20:40:54 +0200 Subject: [PATCH] tools: add a `v bug file.v` tool to automatically report bugs on GitHub (#9746) --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- cmd/tools/vbug.v | 196 +++++++++++++++++++++++++++ cmd/v/help/bug.txt | 8 ++ cmd/v/v.v | 33 ++--- vlib/v/ast/table.v | 4 +- vlib/v/builder/cc.v | 2 +- 6 files changed, 225 insertions(+), 20 deletions(-) create mode 100644 cmd/tools/vbug.v create mode 100644 cmd/v/help/bug.txt diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 41a813bb28..a907ee621a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,7 +4,7 @@ about: Bug report title: '' labels: 'Bug' assignees: '' - +# When updating, make sure to update the template in 'cmd/tools/vbug.v' too --- +**V doctor:** +``` +$vdoctor_output``` + +**What did you do?** +`v -g -o vdbg cmd/v && vdbg $file_path` +{file_content} + +**What did you expect to see?** + +$expected_result + +**What did you see instead?** +``` +$build_output```' + mut encoded_body := urllib.query_escape(raw_body.replace_once('{file_content}', '```v\n$file_content\n```')) + mut generated_uri := 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body' + if generated_uri.len > 8192 { + // GitHub doesn't support URLs longer than 8192 characters + encoded_body = urllib.query_escape(raw_body.replace_once('{file_content}', 'See attached file `$file_path`')) + generated_uri = 'https://github.com/vlang/v/issues/new?labels=Bug&body=$encoded_body' + println('Your file is too big to be submitted. Head over to the following URL and attach your file.') + println(generated_uri) + } else { + open_browser(generated_uri) or { + if is_verbose { + eprintln(err) + } + println(generated_uri) + } + } +} diff --git a/cmd/v/help/bug.txt b/cmd/v/help/bug.txt new file mode 100644 index 0000000000..6eae2eea9c --- /dev/null +++ b/cmd/v/help/bug.txt @@ -0,0 +1,8 @@ +Usage: + v bug [options] FILE + + Open a prefilled bug report on GitHub. + +Options: + -v Enable verbosity while gathering various information + -y Force the submission of the issue, even if an error occured diff --git a/cmd/v/v.v b/cmd/v/v.v index d7a30c919d..7621f0ad68 100644 --- a/cmd/v/v.v +++ b/cmd/v/v.v @@ -11,29 +11,30 @@ import v.builder const ( external_tools = [ - 'fmt', - 'up', - 'vet', - 'self', - 'tracev', - 'symlink', 'bin2v', + 'bug', + 'build-examples', + 'build-tools', + 'build-vbinaries', + 'check-md', + 'complete', + 'doc', + 'doctor', + 'fmt', + 'repl', + 'self', + 'setup-freetype', + 'symlink', 'test', 'test-all', /* runs most of the tests and other checking tools, that will be run by the CI */ + 'test-cleancode', 'test-fmt', 'test-parser', 'test-self', - 'test-cleancode', - 'check-md', - 'repl', - 'complete', - 'build-tools', - 'build-examples', - 'build-vbinaries', - 'setup-freetype', + 'tracev', + 'up', + 'vet', 'wipe-cache', - 'doc', - 'doctor', ] list_of_flags_that_allow_duplicates = ['cc', 'd', 'define', 'cf', 'cflags'] ) diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index c81fd7c855..6cafd8ab94 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -439,7 +439,7 @@ pub fn (t &Table) get_type_symbol(typ Type) &TypeSymbol { return unsafe { &t.type_symbols[idx] } } // this should never happen - t.panic('get_type_symbol: invalid type (typ=$typ idx=$idx). Compiler bug. This should never happen. Please create a GitHub issue. + t.panic('get_type_symbol: invalid type (typ=$typ idx=$idx). Compiler bug. This should never happen. Please report the bug using `v bug file.v`. ') } @@ -456,7 +456,7 @@ pub fn (t &Table) get_final_type_symbol(typ Type) &TypeSymbol { return unsafe { &t.type_symbols[idx] } } // this should never happen - t.panic('get_final_type_symbol: invalid type (typ=$typ idx=$idx). Compiler bug. This should never happen. Please create a GitHub issue.') + t.panic('get_final_type_symbol: invalid type (typ=$typ idx=$idx). Compiler bug. This should never happen. Please report the bug using `v bug file.v`.') } [inline] diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 81be120c87..793c7b9cc1 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -16,7 +16,7 @@ const ( ================== C error. This should never happen. -If you were not working with C interop, this is a compiler bug, please raise an issue on GitHub: +If you were not working with C interop, this is a compiler bug, please report the bug using `v bug file.v`. https://github.com/vlang/v/issues/new/choose