feat(parser/resultdetail): support MaxFilesLength
This commit is contained in:
parent
0df4df339f
commit
5d5bc21447
|
@ -15,6 +15,7 @@ type Conf struct {
|
||||||
ShowMemory bool `default:"true"`
|
ShowMemory bool `default:"true"`
|
||||||
ShowRunTime bool `default:"false"`
|
ShowRunTime bool `default:"false"`
|
||||||
ShowFiles []string
|
ShowFiles []string
|
||||||
|
MaxFilesLength int `default:"2048"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResultDetail struct{}
|
type ResultDetail struct{}
|
||||||
|
@ -56,6 +57,9 @@ func (*ResultDetail) Run(results []stage.ExecutorResult, confAny any) (
|
||||||
content, ok := result.Files[file]
|
content, ok := result.Files[file]
|
||||||
comment += fmt.Sprintf("File `%s`:\n", file)
|
comment += fmt.Sprintf("File `%s`:\n", file)
|
||||||
if ok {
|
if ok {
|
||||||
|
if conf.MaxFilesLength > 0 && len(content) > conf.MaxFilesLength {
|
||||||
|
content = content[:conf.MaxFilesLength] + "\n\n(truncated)"
|
||||||
|
}
|
||||||
comment += fmt.Sprintf("```\n%s\n```\n", content)
|
comment += fmt.Sprintf("```\n%s\n```\n", content)
|
||||||
} else {
|
} else {
|
||||||
comment += "Not found.\n"
|
comment += "Not found.\n"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user