@@ -70,43 +70,6 @@ impl Requirement {
7070 self . source . is_editable ( )
7171 }
7272
73- /// Remove any sensitive credentials from the requirement.
74- #[ must_use]
75- pub fn redact ( self ) -> Requirement {
76- match self . source {
77- RequirementSource :: Git {
78- mut repository,
79- reference,
80- precise,
81- subdirectory,
82- url,
83- } => {
84- // Redact the repository URL, but allow `git@`.
85- redact_credentials ( & mut repository) ;
86-
87- // Redact the PEP 508 URL.
88- let mut url = url. to_url ( ) ;
89- redact_credentials ( & mut url) ;
90- let url = VerbatimUrl :: from_url ( url) ;
91-
92- Self {
93- name : self . name ,
94- extras : self . extras ,
95- marker : self . marker ,
96- source : RequirementSource :: Git {
97- repository,
98- reference,
99- precise,
100- subdirectory,
101- url,
102- } ,
103- origin : self . origin ,
104- }
105- }
106- _ => self ,
107- }
108- }
109-
11073 /// Convert the requirement to a [`Requirement`] relative to the given path.
11174 pub fn relative_to ( self , path : & Path ) -> Result < Self , io:: Error > {
11275 Ok ( Self {
@@ -614,7 +577,15 @@ enum RequirementSourceWire {
614577impl From < RequirementSource > for RequirementSourceWire {
615578 fn from ( value : RequirementSource ) -> Self {
616579 match value {
617- RequirementSource :: Registry { specifier, index } => Self :: Registry { specifier, index } ,
580+ RequirementSource :: Registry {
581+ specifier,
582+ mut index,
583+ } => {
584+ if let Some ( index) = index. as_mut ( ) {
585+ redact_credentials ( index) ;
586+ }
587+ Self :: Registry { specifier, index }
588+ }
618589 RequirementSource :: Url {
619590 subdirectory,
620591 location,
@@ -625,7 +596,7 @@ impl From<RequirementSource> for RequirementSourceWire {
625596 subdirectory : subdirectory
626597 . as_deref ( )
627598 . and_then ( Path :: to_str)
628- . map ( str :: to_string) ,
599+ . map ( ToString :: to_string) ,
629600 } ,
630601 RequirementSource :: Git {
631602 repository,
0 commit comments