@@ -209,10 +209,8 @@ def publish(context: Context, dry_run: str = ""):
209209 "js" : prepare_js_release ,
210210 "py" : prepare_py_release ,
211211 }
212-
213- parsed_tags : list [TagInfo ] = [
214- parse_tag (tag ) for tag in dry_run .split ("," ) or get_current_tags (context )
215- ]
212+ current_tags = dry_run .split ("," ) if dry_run else get_current_tags (context )
213+ parsed_tags = [parse_tag (tag ) for tag in current_tags ]
216214
217215 publishers : list [Callable [[bool ], None ]] = []
218216 for tag_info in parsed_tags :
@@ -315,23 +313,18 @@ def get_current_tags(context: Context) -> set[str]:
315313 context .run ("git diff --cached --exit-code" , hide = True )
316314 context .run ("git diff --exit-code" , hide = True )
317315 except Exception :
318- log .error ("Cannot create a tag - there are uncommitted changes" )
316+ log .error ("Cannot get current tags - there are uncommitted changes" )
319317 return set ()
320318
321- tags_per_commit : dict [str , list [str ]] = {}
322- for commit , tag in map (
323- str .split ,
324- context .run (
325- r"git for-each-ref --format '%(objectname) %(refname:short)' refs/tags" ,
326- hide = True ,
327- ).stdout .splitlines (),
328- ):
329- tags_per_commit .setdefault (commit , []).append (tag )
330-
331- current_commit = context .run (
332- "git rev-parse HEAD" , silent = True , external = True
333- ).stdout .strip ()
334- tags = set (tags_per_commit .get (current_commit , set ()))
319+ # get tags for current commit
320+ tags = {
321+ line
322+ for line in map (
323+ str .strip ,
324+ context .run ("git tag --points-at HEAD" , hide = True ).stdout .splitlines (),
325+ )
326+ if line
327+ }
335328
336329 if not tags :
337330 log .error ("No tags found for current commit" )
0 commit comments