@@ -946,10 +946,7 @@ impl CliUnstable {
946
946
self . add ( flag, & mut warnings) ?;
947
947
}
948
948
949
- if self . gitoxide . is_none ( )
950
- && std:: env:: var_os ( "__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2" )
951
- . map_or ( false , |value| value == "1" )
952
- {
949
+ if self . gitoxide . is_none ( ) && cargo_use_gitoxide_instead_of_git2 ( ) {
953
950
self . gitoxide = GitoxideFeatures :: safe ( ) . into ( ) ;
954
951
}
955
952
Ok ( warnings)
@@ -1171,9 +1168,15 @@ impl CliUnstable {
1171
1168
1172
1169
/// Returns the current release channel ("stable", "beta", "nightly", "dev").
1173
1170
pub fn channel ( ) -> String {
1171
+ // ALLOWED: For testing cargo itself only.
1172
+ #[ allow( clippy:: disallowed_methods) ]
1174
1173
if let Ok ( override_channel) = env:: var ( "__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS" ) {
1175
1174
return override_channel;
1176
1175
}
1176
+ // ALLOWED: the process of rustc boostrapping reads this through
1177
+ // `std::env`. We should make the behavior consistent. Also, we
1178
+ // don't advertise this for bypassing nightly.
1179
+ #[ allow( clippy:: disallowed_methods) ]
1177
1180
if let Ok ( staging) = env:: var ( "RUSTC_BOOTSTRAP" ) {
1178
1181
if staging == "1" {
1179
1182
return "dev" . to_string ( ) ;
@@ -1183,3 +1186,12 @@ pub fn channel() -> String {
1183
1186
. release_channel
1184
1187
. unwrap_or_else ( || String :: from ( "dev" ) )
1185
1188
}
1189
+
1190
+ /// Only for testing and developing. See ["Running with gitoxide as default git backend in tests"][1].
1191
+ ///
1192
+ /// [1]: https://doc.crates.io/contrib/tests/running.html#running-with-gitoxide-as-default-git-backend-in-tests
1193
+ // ALLOWED: For testing cargo itself only.
1194
+ #[ allow( clippy:: disallowed_methods) ]
1195
+ fn cargo_use_gitoxide_instead_of_git2 ( ) -> bool {
1196
+ std:: env:: var_os ( "__CARGO_USE_GITOXIDE_INSTEAD_OF_GIT2" ) . map_or ( false , |value| value == "1" )
1197
+ }
0 commit comments