@@ -946,10 +946,7 @@ impl CliUnstable {
946946 self . add ( flag, & mut warnings) ?;
947947 }
948948
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 ( ) {
953950 self . gitoxide = GitoxideFeatures :: safe ( ) . into ( ) ;
954951 }
955952 Ok ( warnings)
@@ -1171,9 +1168,15 @@ impl CliUnstable {
11711168
11721169/// Returns the current release channel ("stable", "beta", "nightly", "dev").
11731170pub fn channel ( ) -> String {
1171+ // ALLOWED: For testing cargo itself only.
1172+ #[ allow( clippy:: disallowed_methods) ]
11741173 if let Ok ( override_channel) = env:: var ( "__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS" ) {
11751174 return override_channel;
11761175 }
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) ]
11771180 if let Ok ( staging) = env:: var ( "RUSTC_BOOTSTRAP" ) {
11781181 if staging == "1" {
11791182 return "dev" . to_string ( ) ;
@@ -1183,3 +1186,12 @@ pub fn channel() -> String {
11831186 . release_channel
11841187 . unwrap_or_else ( || String :: from ( "dev" ) )
11851188}
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