mirror of
https://github.com/vlang/v.git
synced 2025-09-09 07:15:50 -04:00
tools: colorise the output of cmd/tools/show_ancient_deprecations.v, reduce false positives (#22048)
This commit is contained in:
parent
f879368466
commit
a7e733538e
@ -1,4 +1,5 @@
|
||||
import os
|
||||
import term
|
||||
import time
|
||||
|
||||
struct Context {
|
||||
@ -15,13 +16,13 @@ fn (mut ctx Context) analyze_line(line string, position_file string, position_li
|
||||
ts := blame_for_time.output.all_after('committer-time').all_before('\n').trim_space().int()
|
||||
t := time.unix(ts)
|
||||
if ctx.cut_time < t {
|
||||
println('>>> SKIPPING since t: ${t} > ${ctx.cut_time}, line: ${line}')
|
||||
println(term.colorize(term.gray, '>>> SKIPPING since t: ${t} > ${ctx.cut_time}, ${position_file}:${position_line}: ${line}'))
|
||||
return
|
||||
}
|
||||
ctx.deprecations++
|
||||
blame_for_context := os.execute('git blame -L${position_line},+5 -- ${position_file}')
|
||||
context := blame_for_context.output.trim_space().split_into_lines()
|
||||
println('${position_file}:${position_line}: deprecation: ${ctx.deprecations}, timestamp: ${ts} - ${t}')
|
||||
println(term.colorize(term.red, '${position_file}:${position_line}: deprecation: ${ctx.deprecations}, timestamp: ${ts} - ${t}'))
|
||||
for cline in context {
|
||||
println(' ${cline}')
|
||||
}
|
||||
@ -41,11 +42,11 @@ fn main() {
|
||||
all_v_files := os.walk_ext('.', '.v')
|
||||
for v_file in all_v_files {
|
||||
if v_file == './vlib/v/fmt/tests/attrs_keep.vv' {
|
||||
println('>>> SKIPPING deprecations attrs formatting test file ${v_file}')
|
||||
println(term.colorize(term.gray, '>>> SKIPPING deprecations attrs formatting test file ${v_file}'))
|
||||
continue
|
||||
}
|
||||
if v_file.starts_with('./vlib/v/checker/tests') && v_file.contains('deprec') {
|
||||
println('>>> SKIPPING deprecations test file ${v_file}')
|
||||
println(term.colorize(term.gray, '>>> SKIPPING deprecations test file ${v_file}'))
|
||||
continue
|
||||
}
|
||||
file_content := os.read_file(v_file)!
|
||||
@ -56,6 +57,9 @@ fn main() {
|
||||
for line_num := lines.len - 1; line_num > 0; line_num-- {
|
||||
line := lines[line_num]
|
||||
mut is_deprecation_line := false
|
||||
if line.contains('\tif ') {
|
||||
continue
|
||||
}
|
||||
if line.contains('[deprecated:') {
|
||||
is_deprecation_line = true
|
||||
}
|
||||
@ -68,5 +72,9 @@ fn main() {
|
||||
ctx.analyze_line(line, v_file, line_num + 1)
|
||||
}
|
||||
}
|
||||
println('> Summary: there were ${ctx.deprecations} deprecations found, done before ${cut_time}.')
|
||||
println('> Summary: there were ${term.colorize(term.bright_yellow, ctx.deprecations.str())} deprecations found, done before ${term.colorize(term.magenta,
|
||||
cut_time.str())}.')
|
||||
if ctx.deprecations > 0 {
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user