File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ fn get_latest_upstream_commit_that_modified_files(
198198/// author.
199199///
200200/// If we are in CI, we simply return our first parent.
201- fn get_closest_upstream_commit (
201+ pub fn get_closest_upstream_commit (
202202 git_dir : Option < & Path > ,
203203 config : & GitConfig < ' _ > ,
204204 env : CiEnv ,
Original file line number Diff line number Diff line change 33
44use std:: process:: Command ;
55
6+ use build_helper:: ci:: CiEnv ;
7+ use build_helper:: git:: { GitConfig , get_closest_upstream_commit} ;
8+
69fn git_diff ( base_commit : & str , extra_arg : & str ) -> Option < String > {
710 let output = Command :: new ( "git" ) . arg ( "diff" ) . arg ( base_commit) . arg ( extra_arg) . output ( ) . ok ( ) ?;
811 Some ( String :: from_utf8_lossy ( & output. stdout ) . into ( ) )
912}
1013
1114pub fn check ( bad : & mut bool ) {
12- let Ok ( base_commit) = std:: env:: var ( "BASE_COMMIT" ) else {
13- // Not in CI so nothing we can check here.
14- println ! ( "not checking rustdoc JSON `FORMAT_VERSION` update" ) ;
15- return ;
15+ let base_commit = match get_closest_upstream_commit (
16+ None ,
17+ & GitConfig { nightly_branch : "" , git_merge_commit_email : "bors@rust-lang.org" } ,
18+ CiEnv :: current ( ) ,
19+ ) {
20+ Ok ( Some ( commit) ) => commit,
21+ Ok ( None ) => {
22+ eprintln ! ( "No base commit found, skipping rustdoc_json check" ) ;
23+ return ;
24+ }
25+ Err ( error) => {
26+ eprintln ! (
27+ "Failed to retrieve base commit for rustdoc_json check because of `{error}`, skipping it"
28+ ) ;
29+ return ;
30+ }
1631 } ;
1732
1833 // First we check that `src/rustdoc-json-types` was modified.
You can’t perform that action at this time.
0 commit comments