@@ -134,7 +134,8 @@ impl LockstepApiSpecFileName {
134134
135135impl fmt:: Display for LockstepApiSpecFileName {
136136 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
137- f. write_str ( self . path ( ) . as_str ( ) )
137+ // For lockstep files, path == basename (no directory prefix).
138+ f. write_str ( & self . basename ( ) )
138139 }
139140}
140141
@@ -203,7 +204,12 @@ impl VersionedApiSpecFileName {
203204
204205 /// Returns the base name of this file path.
205206 pub fn basename ( & self ) -> String {
206- match self . kind {
207+ self . basename_for_kind ( self . kind )
208+ }
209+
210+ /// Returns the base name for a specific storage kind.
211+ fn basename_for_kind ( & self , kind : VersionedApiSpecKind ) -> String {
212+ match kind {
207213 VersionedApiSpecKind :: Json => {
208214 format ! ( "{}-{}-{}.json" , self . ident, self . version, self . hash)
209215 }
@@ -245,21 +251,22 @@ impl VersionedApiSpecFileName {
245251 /// - If already a Git stub, returns `basename()` directly.
246252 /// - If JSON, returns `basename() + ".gitstub"`.
247253 pub fn git_stub_basename ( & self ) -> String {
248- self . to_git_stub ( ) . basename ( )
254+ self . basename_for_kind ( VersionedApiSpecKind :: GitStub )
249255 }
250256
251257 /// Returns the basename as a JSON filename.
252258 ///
253259 /// - If already JSON, returns `basename()` directly.
254260 /// - If Git stub, returns the basename without `.gitstub`.
255261 pub fn json_basename ( & self ) -> String {
256- self . to_json ( ) . basename ( )
262+ self . basename_for_kind ( VersionedApiSpecKind :: Json )
257263 }
258264}
259265
260266impl fmt:: Display for VersionedApiSpecFileName {
261267 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
262- f. write_str ( self . path ( ) . as_str ( ) )
268+ // path = "{ident}/{basename}".
269+ write ! ( f, "{}/{}" , self . ident, self . basename( ) )
263270 }
264271}
265272
@@ -288,7 +295,10 @@ pub enum ApiSpecFileName {
288295
289296impl fmt:: Display for ApiSpecFileName {
290297 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
291- f. write_str ( self . path ( ) . as_str ( ) )
298+ match self {
299+ ApiSpecFileName :: Lockstep ( l) => fmt:: Display :: fmt ( l, f) ,
300+ ApiSpecFileName :: Versioned ( v) => fmt:: Display :: fmt ( v, f) ,
301+ }
292302 }
293303}
294304
0 commit comments