@@ -3,8 +3,10 @@ use xshell::Shell;
33
44pub ( crate ) fn check_changelog ( shell : Shell , mut args : Arguments ) -> anyhow:: Result < ( ) > {
55 const CHANGELOG_PATH_RELATIVE : & str = "./CHANGELOG.md" ;
6+ const WARN_LABEL : & str = "changelog: released entry changed" ;
67
78 let emit_github_messages = args. contains ( "--emit-github-messages" ) ;
9+ let warn_only = args. contains ( "--warn-only" ) ;
810
911 let from_branch = args
1012 . free_from_str ( )
@@ -65,11 +67,24 @@ pub(crate) fn check_changelog(shell: Shell, mut args: Arguments) -> anyhow::Resu
6567 eprintln ! ( "{}" , hunk. contents) ;
6668
6769 if emit_github_messages {
70+ let severity = if warn_only { "warning" } else { "error" } ;
6871 let title = "Released changelog content changed" ;
69- let message =
72+ let mut message =
7073 "This PR changes changelog content that is already released." . to_owned ( ) ;
74+ if !warn_only {
75+ // NOTE: Keep this label name in sync. with CI's branching logic.
76+ message += & format ! (
77+ concat!(
78+ "\n \n " ,
79+ "If you know what you're doing, " ,
80+ "you can add the `{}` label " ,
81+ "and reduce this error's severity to a warning."
82+ ) ,
83+ WARN_LABEL
84+ ) ;
85+ }
7186 println ! (
72- "::error file=CHANGELOG.md,line={},endLine={},title={title}::{message}" ,
87+ "::{severity} file=CHANGELOG.md,line={},endLine={},title={title}::{message}" ,
7388 hunk. change_start_line_num, hunk. change_end_line_num,
7489 )
7590 }
@@ -82,7 +97,12 @@ pub(crate) fn check_changelog(shell: Shell, mut args: Arguments) -> anyhow::Resu
8297 "one or more checks against `{}` failed; see above for details" ,
8398 CHANGELOG_PATH_RELATIVE ,
8499 ) ;
85- Err ( anyhow:: Error :: msg ( msg) )
100+ if warn_only {
101+ log:: warn!( "{msg}" ) ;
102+ Ok ( ( ) )
103+ } else {
104+ Err ( anyhow:: Error :: msg ( msg) )
105+ }
86106 } else {
87107 Ok ( ( ) )
88108 }
0 commit comments