Skip to content

Commit

Permalink
feat (docs): allow to list more tags for github
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Jan 29, 2024
1 parent 9a26fee commit a25cc56
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/diracdoctools/scripts/dirac-docs-get-release-notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ def gitlabSetup(GITLABTOKEN=""):
SESSION.headers.update({"PRIVATE-TOKEN": GITLABTOKEN})


def req2Json(url, parameterDict=None, requestType="GET"):
def req2Json(url, parameterDict=None, requestType="GET", queryParameters=None):
"""Call to github API using requests package."""
log = LOGGER.getChild("Requests")
log.debug("Running %s with %s ", requestType, parameterDict)
req = getattr(SESSION, requestType.lower())(url, json=parameterDict)
req = getattr(SESSION, requestType.lower())(url, json=parameterDict, params=queryParameters)
if req.status_code not in (200, 201):
log.error("Unable to access API: %s", req.text)
raise RuntimeError("Failed to access API")
Expand Down Expand Up @@ -433,7 +433,7 @@ def parseOptions(self):
for var, val in sorted(vars(parsed).items()):
log.info("Using options: %s = %s", var, pformat(val))

def _github(self, action):
def _github(self, action, per_page=None):
"""Return the url to perform actions on github.
:param str action: command to use in the gitlab API, see documentation there
Expand All @@ -442,6 +442,7 @@ def _github(self, action):
log = LOGGER.getChild("GitHub")
options = dict(self._options)
options["action"] = action

ghURL = f"https://api.github.com/repos/{options['owner']}/{options['repo']}/{options['action']}"
log.debug("Calling: %s", ghURL)
return ghURL
Expand Down Expand Up @@ -504,7 +505,7 @@ def getGithubLatestTagDate(self, sinceTag):
log = LOGGER.getChild("getGithubLatestTagDate")

# Get all tags
tags = req2Json(url=self._github("tags"))
tags = req2Json(url=self._github("tags"), queryParameters={"per_page": 100})
if isinstance(tags, dict) and "Not Found" in tags.get("message"):
raise RuntimeError(f"Package not found: {str(self)}")

Expand Down

0 comments on commit a25cc56

Please sign in to comment.