Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve deprecate logs #2841

Merged
merged 1 commit into from Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions internal/deprecate/deprecate.go
Expand Up @@ -43,10 +43,14 @@ func Notice(ctx *context.Context, property string) {
// NoticeCustom warns the user about the deprecation of the given property.
func NoticeCustom(ctx *context.Context, property, tmpl string) {
ctx.Deprecated = true
cli.Default.Padding += 3
defer func() {
cli.Default.Padding -= 3
}()
// XXX: this is very ugly!
w := log.Log.(*log.Logger).Handler.(*cli.Handler).Writer
handler := cli.New(w)
handler.Padding = cli.Default.Padding + 3
log := &log.Logger{
Handler: handler,
Level: log.InfoLevel,
}
// replaces . and _ with -
url := baseURL + strings.NewReplacer(
".", "",
Expand Down
2 changes: 1 addition & 1 deletion internal/deprecate/testdata/TestNotice.txt.golden
@@ -1,3 +1,3 @@
• first
• DEPRECATED: `foo.bar.whatever` should not be used anymore, check https://goreleaser.com/deprecations#foobarwhatever for more info
• DEPRECATED: `foo.bar.whatever` should not be used anymore, check https://goreleaser.com/deprecations#foobarwhatever for more info
• last
2 changes: 1 addition & 1 deletion internal/deprecate/testdata/TestNoticeCustom.txt.golden
@@ -1,3 +1,3 @@
• first
• DEPRECATED: some custom template with a url https://goreleaser.com/deprecations#something-else
• DEPRECATED: some custom template with a url https://goreleaser.com/deprecations#something-else
• last