File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
src/bootstrap/src/core/config Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -1168,8 +1168,15 @@ impl Config {
11681168 "WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
11691169 ) ;
11701170
1171- let channel =
1172- config. read_file_by_commit ( Path :: new ( "src/ci/channel" ) , commit) . trim ( ) . to_owned ( ) ;
1171+ let channel = read_file_by_commit (
1172+ & config. exec_ctx ,
1173+ & config. src ,
1174+ & config. rust_info ,
1175+ Path :: new ( "src/ci/channel" ) ,
1176+ commit,
1177+ )
1178+ . trim ( )
1179+ . to_owned ( ) ;
11731180
11741181 config. channel = channel;
11751182 }
@@ -2746,3 +2753,21 @@ pub(crate) fn ci_llvm_root(
27462753 assert ! ( llvm_from_ci) ;
27472754 out. join ( host_target) . join ( "ci-llvm" )
27482755}
2756+
2757+ /// Returns the content of the given file at a specific commit.
2758+ pub ( crate ) fn read_file_by_commit (
2759+ exec_ctx : & ExecutionContext ,
2760+ src : & Path ,
2761+ rust_info : & channel:: GitInfo ,
2762+ file : & Path ,
2763+ commit : & str ,
2764+ ) -> String {
2765+ assert ! (
2766+ rust_info. is_managed_git_subrepository( ) ,
2767+ "`Config::read_file_by_commit` is not supported in non-git sources."
2768+ ) ;
2769+
2770+ let mut git = helpers:: git ( Some ( src) ) ;
2771+ git. arg ( "show" ) . arg ( format ! ( "{commit}:{}" , file. to_str( ) . unwrap( ) ) ) ;
2772+ git. run_capture_stdout ( exec_ctx) . stdout ( )
2773+ }
You can’t perform that action at this time.
0 commit comments