diff --git a/README.rst b/README.rst index b9fc86e..7748608 100644 --- a/README.rst +++ b/README.rst @@ -286,9 +286,14 @@ use_latest_release includes both annotated tags and lightweight ones. use_max_tag - Set this to ``true`` to check for the max tag on GitHub. Unlike ``use_latest_release``, - this option includes both annotated tags and lightweight ones, and return the biggest one - sorted by ``pkg_resources.parse_version``. + Set this to ``true`` to check for the max tag on GitHub. Unlike + ``use_latest_release``, this option includes both annotated tags and + lightweight ones, and return the largest one sorted by the + ``sort_version_key`` option. + +max_page + How many pages do we search for the max tag? Default is 3. This works when + ``use_max_tag`` is set. proxy The HTTP proxy to use. The format is ``host:port``, e.g. ``localhost:8087``. @@ -300,7 +305,7 @@ An environment variable ``NVCHECKER_GITHUB_TOKEN`` or a key named ``github`` can be set to a GitHub OAuth token in order to request more frequently than anonymously. -This source supports `list options`_ when ``use_latest_release`` or ``use_max_tag`` is set. +This source supports `list options`_ when ``use_max_tag`` is set. Check BitBucket --------------- diff --git a/nvchecker/source/github.py b/nvchecker/source/github.py index 5ac5985..54eebf1 100644 --- a/nvchecker/source/github.py +++ b/nvchecker/source/github.py @@ -62,6 +62,7 @@ async def get_version_real(name, conf, **kwargs): return await max_tag(partial( session.get, headers=headers, **kwargs), url, name, ignored_tags, include_tags_pattern, + max_page = conf.get("max_page", 3), ) async with session.get(url, headers=headers, **kwargs) as res: @@ -84,11 +85,12 @@ async def get_version_real(name, conf, **kwargs): return version async def max_tag( - getter, url, name, ignored_tags, include_tags_pattern, + getter, url, name, ignored_tags, include_tags_pattern, max_page, ): # paging is needed + tags = [] - while True: + for _ in range(max_page): async with getter(url) as res: logger.debug('X-RateLimit-Remaining', n=res.headers.get('X-RateLimit-Remaining')) @@ -100,7 +102,7 @@ async def max_tag( data = [x for x in data if re.search(include_tags_pattern, x)] if data: - return data + tags += data else: next_page_url = get_next_page_url(links) if not next_page_url: @@ -111,7 +113,7 @@ async def max_tag( logger.error('No tag found in upstream repository.', name=name, include_tags_pattern=include_tags_pattern) - return + return tags def get_next_page_url(links): links = links.split(', ')