refactor(comments): Clean up formatting
Clean up formatting of the comments and simplify it. Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
f800164085
commit
53deef6627
1 changed files with 3 additions and 7 deletions
|
@ -13,16 +13,14 @@ func GetSeparatorForMultiline(config *Config) string {
|
|||
if config.Language.OpeningOnSeparateLine {
|
||||
return "\n"
|
||||
}
|
||||
return " "
|
||||
return ""
|
||||
}
|
||||
|
||||
func FormatComment(config *Config, body string, beenWrapped bool) string {
|
||||
if beenWrapped && !config.Language.OpeningOnSeparateLine {
|
||||
body = " " + strings.TrimPrefix(body, " "+config.Language.Continuation)
|
||||
}
|
||||
if !beenWrapped && !config.Language.OpeningOnSeparateLine && !strings.HasSuffix(body, "\n") {
|
||||
body = body + "\n"
|
||||
body = strings.TrimPrefix(body, config.Language.Continuation)
|
||||
}
|
||||
body = strings.TrimRightFunc(body, unicode.IsSpace)
|
||||
return fmt.Sprintf("%s%s%s", config.Language.Opening, body, config.Language.Closing)
|
||||
}
|
||||
|
||||
|
@ -32,8 +30,6 @@ func ProcessComment(config *Config, wrapper *wrap.Wrapper, comment *gitea.PullRe
|
|||
beenWrapped := len(body)+len(config.Language.Opening)+len(config.Language.Closing) > 100
|
||||
if beenWrapped {
|
||||
body = GetSeparatorForMultiline(config) + wrapper.Wrap(body, 100)
|
||||
} else {
|
||||
body = " " + body
|
||||
}
|
||||
|
||||
body = strings.Replace(body, "\r", "", -1)
|
||||
|
|
Loading…
Reference in a new issue