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 {
1168
1168
"WARNING: `rust.download-rustc` is enabled. The `rust.channel` option will be overridden by the CI rustc's channel."
1169
1169
) ;
1170
1170
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 ( ) ;
1173
1180
1174
1181
config. channel = channel;
1175
1182
}
@@ -2746,3 +2753,21 @@ pub(crate) fn ci_llvm_root(
2746
2753
assert ! ( llvm_from_ci) ;
2747
2754
out. join ( host_target) . join ( "ci-llvm" )
2748
2755
}
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