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
}
@@ -2751,3 +2758,21 @@ pub(crate) fn ci_llvm_root(
2751
2758
assert ! ( llvm_from_ci) ;
2752
2759
out. join ( host_target) . join ( "ci-llvm" )
2753
2760
}
2761
+
2762
+ /// Returns the content of the given file at a specific commit.
2763
+ pub ( crate ) fn read_file_by_commit (
2764
+ exec_ctx : & ExecutionContext ,
2765
+ src : & Path ,
2766
+ rust_info : & channel:: GitInfo ,
2767
+ file : & Path ,
2768
+ commit : & str ,
2769
+ ) -> String {
2770
+ assert ! (
2771
+ rust_info. is_managed_git_subrepository( ) ,
2772
+ "`Config::read_file_by_commit` is not supported in non-git sources."
2773
+ ) ;
2774
+
2775
+ let mut git = helpers:: git ( Some ( src) ) ;
2776
+ git. arg ( "show" ) . arg ( format ! ( "{commit}:{}" , file. to_str( ) . unwrap( ) ) ) ;
2777
+ git. run_capture_stdout ( exec_ctx) . stdout ( )
2778
+ }
You can’t perform that action at this time.
0 commit comments