@@ -161,9 +161,22 @@ impl Adapter for GenericAdapter {
161161 Bump :: Patch
162162 }
163163
164- fn is_published ( & self , _pkg : & Pkg , _version : & str ) -> Result < bool > {
165- // No registry API to query; rely on the dated changelog / tag for idempotency upstream.
166- Ok ( false )
164+ fn is_published ( & self , pkg : & Pkg , version : & str ) -> Result < bool > {
165+ // No generic registry API exists, so use the tag created after a successful publish as
166+ // the resumability marker.
167+ let tag = format ! ( "{}@{}" , pkg. name, version) ;
168+ let out = Command :: new ( "git" )
169+ . args ( [ "tag" , "--list" , & tag] )
170+ . current_dir ( & self . root )
171+ . output ( )
172+ . with_context ( || format ! ( "checking for release tag: {tag}" ) ) ?;
173+ if !out. status . success ( ) {
174+ bail ! (
175+ "`git tag --list {tag}` failed:\n {}" ,
176+ String :: from_utf8_lossy( & out. stderr)
177+ ) ;
178+ }
179+ Ok ( !String :: from_utf8_lossy ( & out. stdout ) . trim ( ) . is_empty ( ) )
167180 }
168181
169182 fn publish ( & self , pkg : & Pkg , _staged_assets : Option < & Path > ) -> Result < ( ) > {
@@ -253,4 +266,46 @@ mod tests {
253266 let p = a. discover_packages ( ) . unwrap ( ) . pop ( ) . unwrap ( ) ;
254267 assert ! ( a. publish( & p, None ) . is_err( ) ) ;
255268 }
269+
270+ #[ test]
271+ fn is_published_uses_existing_release_tag ( ) {
272+ let tmp = tempfile:: tempdir ( ) . unwrap ( ) ;
273+ std:: fs:: write ( tmp. path ( ) . join ( "deno.json" ) , "{\" version\" :\" 1.0.0\" }" ) . unwrap ( ) ;
274+ std:: process:: Command :: new ( "git" )
275+ . args ( [ "init" , "-q" ] )
276+ . current_dir ( tmp. path ( ) )
277+ . status ( )
278+ . unwrap ( ) ;
279+ std:: process:: Command :: new ( "git" )
280+ . args ( [ "config" , "user.email" , "t@t" ] )
281+ . current_dir ( tmp. path ( ) )
282+ . status ( )
283+ . unwrap ( ) ;
284+ std:: process:: Command :: new ( "git" )
285+ . args ( [ "config" , "user.name" , "Test" ] )
286+ . current_dir ( tmp. path ( ) )
287+ . status ( )
288+ . unwrap ( ) ;
289+ std:: process:: Command :: new ( "git" )
290+ . args ( [ "add" , "-A" ] )
291+ . current_dir ( tmp. path ( ) )
292+ . status ( )
293+ . unwrap ( ) ;
294+ std:: process:: Command :: new ( "git" )
295+ . args ( [ "commit" , "-q" , "-m" , "init" ] )
296+ . current_dir ( tmp. path ( ) )
297+ . status ( )
298+ . unwrap ( ) ;
299+
300+ let a = GenericAdapter :: new ( tmp. path ( ) , vec ! [ pkg( "lib" , "deno.json" , Some ( "true" ) ) ] ) ;
301+ let p = a. discover_packages ( ) . unwrap ( ) . pop ( ) . unwrap ( ) ;
302+ assert ! ( !a. is_published( & p, "1.0.0" ) . unwrap( ) ) ;
303+
304+ std:: process:: Command :: new ( "git" )
305+ . args ( [ "tag" , "lib@1.0.0" ] )
306+ . current_dir ( tmp. path ( ) )
307+ . status ( )
308+ . unwrap ( ) ;
309+ assert ! ( a. is_published( & p, "1.0.0" ) . unwrap( ) ) ;
310+ }
256311}
0 commit comments