@@ -120,7 +120,7 @@ struct Repo {
120120 inner : gix:: Repository ,
121121}
122122
123- fn path_to_python ( py : Python < ' _ > , path : & Path ) -> PyResult < PyObject > {
123+ fn path_to_python ( py : Python < ' _ > , path : & Path ) -> PyResult < Py < PyAny > > {
124124 let pathlib = py. import ( "pathlib" ) ?;
125125 let path_class = pathlib. getattr ( "Path" ) ?;
126126 Ok ( path_class. call1 ( ( path. as_os_str ( ) , ) ) ?. into ( ) )
@@ -138,13 +138,13 @@ fn shorten_reference_name(reference: &gix::Reference) -> String {
138138impl Repo {
139139 /// The path to the `.git` directory of the repository.
140140 #[ getter]
141- fn git_dir ( & self , py : Python ) -> PyResult < PyObject > {
141+ fn git_dir ( & self , py : Python ) -> PyResult < Py < PyAny > > {
142142 path_to_python ( py, self . inner . git_dir ( ) )
143143 }
144144
145145 /// The path to the working tree directory, if present.
146146 #[ getter]
147- fn working_tree_dir ( & self , py : Python ) -> PyResult < Option < PyObject > > {
147+ fn working_tree_dir ( & self , py : Python ) -> PyResult < Option < Py < PyAny > > > {
148148 match self . inner . workdir ( ) {
149149 Some ( path) => Ok ( Some ( path_to_python ( py, path) ?) ) ,
150150 None => Ok ( None ) ,
@@ -202,30 +202,10 @@ impl Repo {
202202 }
203203 }
204204
205- /// Return the names of all local branches in the repository.
206- fn branches ( & self ) -> PyResult < Vec < String > > {
207- let platform = self . inner . references ( ) . map_err ( |err| {
208- PyRuntimeError :: new_err ( format ! ( "Failed to access references: {err}" ) )
209- } ) ?;
210-
211- let iter = platform. local_branches ( ) . map_err ( |err| {
212- PyRuntimeError :: new_err ( format ! ( "Failed to list local branches: {err}" ) )
213- } ) ?;
214-
215- let branches: BTreeSet < String > = iter
216- . map ( |reference_result| {
217- reference_result. map_err ( |err| {
218- PyRuntimeError :: new_err ( format ! (
219- "Failed to load branch reference: {err}"
220- ) )
221- } )
222- } )
223- . collect :: < Result < Vec < _ > , _ > > ( ) ?
224- . into_iter ( )
225- . map ( |reference| shorten_reference_name ( & reference) )
226- . collect ( ) ;
227-
228- Ok ( branches. into_iter ( ) . collect ( ) )
205+ /// Return all local branches in the repository.
206+ #[ getter]
207+ fn branches ( & self ) -> PyResult < Vec < Head > > {
208+ self . heads ( )
229209 }
230210
231211 /// Return the path to the current active branch, if any.
0 commit comments