10
10
//! but forgot to bump its version.
11
11
//! ```
12
12
13
+ #![ allow( clippy:: print_stdout) ] // Fine for build utilities
14
+
13
15
use std:: collections:: HashMap ;
14
16
use std:: fmt:: Write ;
15
17
use std:: fs;
@@ -56,6 +58,7 @@ pub fn cli() -> clap::Command {
56
58
. arg ( flag ( "locked" , "Require Cargo.lock to be up-to-date" ) . global ( true ) )
57
59
. arg ( flag ( "offline" , "Run without accessing the network" ) . global ( true ) )
58
60
. arg ( multi_opt ( "config" , "KEY=VALUE" , "Override a configuration value" ) . global ( true ) )
61
+ . arg ( flag ( "github" , "Group output using GitHub's syntax" ) )
59
62
. arg (
60
63
Arg :: new ( "unstable-features" )
61
64
. help ( "Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details" )
@@ -114,7 +117,7 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
114
117
let base_commit = get_base_commit ( gctx, args, & repo) ?;
115
118
let head_commit = get_head_commit ( args, & repo) ?;
116
119
let referenced_commit = get_referenced_commit ( & repo, & base_commit) ?;
117
- let changed_members = changed ( & ws , & repo , & base_commit , & head_commit ) ? ;
120
+ let github = args . get_flag ( "github" ) ;
118
121
let status = |msg : & str | gctx. shell ( ) . status ( STATUS , msg) ;
119
122
120
123
let crates_not_check_against_channels = [
@@ -135,9 +138,11 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
135
138
status ( & format ! ( "head commit `{}`" , head_commit. id( ) ) ) ?;
136
139
137
140
let mut needs_bump = Vec :: new ( ) ;
138
-
141
+ if github {
142
+ println ! ( "::group::Checking for bumps of changed packages" ) ;
143
+ }
144
+ let changed_members = changed ( & ws, & repo, & base_commit, & head_commit) ?;
139
145
check_crates_io ( & ws, & changed_members, & mut needs_bump) ?;
140
-
141
146
if let Some ( referenced_commit) = referenced_commit. as_ref ( ) {
142
147
status ( & format ! ( "compare against `{}`" , referenced_commit. id( ) ) ) ?;
143
148
for referenced_member in checkout_ws ( & ws, & repo, referenced_commit) ?. members ( ) {
@@ -157,7 +162,6 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
157
162
}
158
163
}
159
164
}
160
-
161
165
if !needs_bump. is_empty ( ) {
162
166
needs_bump. sort ( ) ;
163
167
needs_bump. dedup ( ) ;
@@ -169,18 +173,14 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
169
173
msg. push_str ( "\n Please bump at least one patch version in each corresponding Cargo.toml." ) ;
170
174
anyhow:: bail!( msg)
171
175
}
172
-
173
- // Even when we test against baseline-rev, we still need to make sure a
174
- // change doesn't violate SemVer rules against crates.io releases. The
175
- // possibility of this happening is nearly zero but no harm to check twice.
176
- let mut cmd = ProcessBuilder :: new ( "cargo" ) ;
177
- cmd. arg ( "semver-checks" )
178
- . arg ( "check-release" )
179
- . arg ( "--workspace" ) ;
180
- gctx. shell ( ) . status ( "Running" , & cmd) ?;
181
- cmd. exec ( ) ?;
176
+ if github {
177
+ println ! ( "::endgroup::" ) ;
178
+ }
182
179
183
180
if let Some ( referenced_commit) = referenced_commit. as_ref ( ) {
181
+ if github {
182
+ println ! ( "::group::SemVer Checks against {}" , referenced_commit. id( ) ) ;
183
+ }
184
184
let mut cmd = ProcessBuilder :: new ( "cargo" ) ;
185
185
cmd. arg ( "semver-checks" )
186
186
. arg ( "--workspace" )
@@ -192,6 +192,25 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car
192
192
}
193
193
gctx. shell ( ) . status ( "Running" , & cmd) ?;
194
194
cmd. exec ( ) ?;
195
+ if github {
196
+ println ! ( "::endgroup::" ) ;
197
+ }
198
+ }
199
+
200
+ // Even when we test against baseline-rev, we still need to make sure a
201
+ // change doesn't violate SemVer rules against crates.io releases. The
202
+ // possibility of this happening is nearly zero but no harm to check twice.
203
+ if github {
204
+ println ! ( "::group::SemVer Checks against crates.io" ) ;
205
+ }
206
+ let mut cmd = ProcessBuilder :: new ( "cargo" ) ;
207
+ cmd. arg ( "semver-checks" )
208
+ . arg ( "check-release" )
209
+ . arg ( "--workspace" ) ;
210
+ gctx. shell ( ) . status ( "Running" , & cmd) ?;
211
+ cmd. exec ( ) ?;
212
+ if github {
213
+ println ! ( "::endgroup::" ) ;
195
214
}
196
215
197
216
status ( "no version bump needed for member crates." ) ?;
0 commit comments