@@ -504,26 +504,35 @@ def getGithubLatestTagDate(self, sinceTag):
504504 """
505505 log = LOGGER .getChild ("getGithubLatestTagDate" )
506506
507- # Get all tags
508- tags = req2Json (url = self ._github ("tags" ), queryParameters = {"per_page" : 100 })
509- if isinstance (tags , dict ) and "Not Found" in tags .get ("message" ):
510- raise RuntimeError (f"Package not found: { str (self )} " )
511-
512507 if sinceTag :
513- for tag in tags :
514- if tag ["name" ] == sinceTag :
515- latestTag = tag
508+ # Look the tag up directly as there are more tags than fit in a single page of
509+ # the "tags" endpoint. This matches any tag starting with sinceTag so the exact
510+ # match still has to be picked out of the results.
511+ refs = req2Json (url = self ._github (f"git/matching-refs/tags/{ sinceTag } " ), queryParameters = {"per_page" : 100 })
512+ for ref in refs :
513+ if ref ["ref" ] == f"refs/tags/{ sinceTag } " :
516514 break
517515 else :
518516 raise ValueError (f"Tag { sinceTag } not found" )
517+ latestTagName = sinceTag
518+ latestTagCommitSha = ref ["object" ]["sha" ]
519+ if ref ["object" ]["type" ] == "tag" :
520+ # Annotated tags have to be dereferenced to find the commit they point at
521+ tagInfo = req2Json (url = self ._github (f"git/tags/{ latestTagCommitSha } " ))
522+ latestTagCommitSha = tagInfo ["object" ]["sha" ]
519523 else :
524+ # Get all tags
525+ tags = req2Json (url = self ._github ("tags" ), queryParameters = {"per_page" : 100 })
526+ if isinstance (tags , dict ) and "Not Found" in tags .get ("message" ):
527+ raise RuntimeError (f"Package not found: { str (self )} " )
528+
520529 sortedTags = sorted (tags , key = lambda tag : LooseVersion (tag ["name" ]), reverse = True )
521- latestTag = sortedTags [0 ]
530+ latestTagName = sortedTags [0 ]["name" ]
531+ latestTagCommitSha = sortedTags [0 ]["commit" ]["sha" ]
522532
523- log .info ("Found latest tag %s" , latestTag [ "name" ] )
533+ log .info ("Found latest tag %s" , latestTagName )
524534
525535 # Use the sha of the commit to finally retrieve the date
526- latestTagCommitSha = latestTag ["commit" ]["sha" ]
527536 commitInfo = req2Json (url = self ._github (f"git/commits/{ latestTagCommitSha } " ))
528537
529538 startDate = dateutil .parser .isoparse (commitInfo ["committer" ]["date" ])
0 commit comments