70
70
}
71
71
72
72
///
73
- pub mod to_mapping {
73
+ pub mod to_map {
74
74
use crate :: remote:: { fetch, Connection } ;
75
75
use git_features:: progress:: Progress ;
76
76
use git_protocol:: transport:: client:: Transport ;
@@ -81,6 +81,8 @@ pub mod to_mapping {
81
81
pub enum Error {
82
82
#[ error( transparent) ]
83
83
ListRefs ( #[ from] crate :: remote:: list_refs:: Error ) ,
84
+ #[ error( transparent) ]
85
+ MappingValidation ( #[ from] git_refspec:: match_group:: validate:: Error ) ,
84
86
}
85
87
86
88
impl < ' a , ' repo , T , P > Connection < ' a , ' repo , T , P >
@@ -96,20 +98,32 @@ pub mod to_mapping {
96
98
///
97
99
/// Note that this doesn't fetch the objects mentioned in the tips nor does it make any change to underlying repository.
98
100
#[ git_protocol:: maybe_async:: maybe_async]
99
- pub async fn list_refs_to_mapping ( mut self ) -> Result < Vec < fetch:: Mapping > , Error > {
100
- let mappings = self . ref_mapping ( ) . await ?;
101
+ pub async fn list_refs_to_map ( mut self ) -> Result < fetch:: RefMap , Error > {
102
+ let mappings = self . ref_map ( ) . await ?;
101
103
git_protocol:: fetch:: indicate_end_of_interaction ( & mut self . transport )
102
104
. await
103
105
. map_err ( |err| Error :: ListRefs ( crate :: remote:: list_refs:: Error :: Transport ( err) ) ) ?;
104
106
Ok ( mappings)
105
107
}
106
108
107
109
#[ git_protocol:: maybe_async:: maybe_async]
108
- async fn ref_mapping ( & mut self ) -> Result < Vec < fetch:: Mapping > , Error > {
109
- let _res = self . fetch_refs ( ) . await ?;
110
- let _group = git_refspec:: MatchGroup :: from_fetch_specs ( self . remote . fetch_specs . iter ( ) . map ( |s| s. to_ref ( ) ) ) ;
111
- // group.match_remotes(res.refs.iter().map(|r| r.unpack()))
112
- Ok ( Vec :: new ( ) )
110
+ async fn ref_map ( & mut self ) -> Result < fetch:: RefMap , Error > {
111
+ let res = self . fetch_refs ( ) . await ?;
112
+ let group = git_refspec:: MatchGroup :: from_fetch_specs ( self . remote . fetch_specs . iter ( ) . map ( |s| s. to_ref ( ) ) ) ;
113
+ let ( _res, fixes) = group
114
+ . match_remotes ( res. refs . iter ( ) . map ( |r| {
115
+ let ( full_ref_name, target, object) = r. unpack ( ) ;
116
+ git_refspec:: match_group:: Item {
117
+ full_ref_name,
118
+ target,
119
+ object,
120
+ }
121
+ } ) )
122
+ . validated ( ) ?;
123
+ Ok ( fetch:: RefMap {
124
+ mappings : Vec :: new ( ) ,
125
+ fixes,
126
+ } )
113
127
}
114
128
}
115
129
}
0 commit comments