diff --git a/nvchecker/source/github.py b/nvchecker/source/github.py index 526576b..77c2a69 100644 --- a/nvchecker/source/github.py +++ b/nvchecker/source/github.py @@ -2,6 +2,7 @@ # Copyright (c) 2013-2017 lilydjwg , et al. import os +import logging from . import session from ..sortversion import sort_version_keys @@ -10,6 +11,8 @@ GITHUB_URL = 'https://api.github.com/repos/%s/commits?sha=%s' GITHUB_LATEST_RELEASE = 'https://api.github.com/repos/%s/releases/latest' GITHUB_MAX_TAG = 'https://api.github.com/repos/%s/tags' +logger = logging.getLogger(__name__) + async def get_version(name, conf): repo = conf.get('github') br = conf.get('branch', 'master') @@ -36,10 +39,16 @@ async def get_version(name, conf): async with session.get(url, headers=headers, **kwargs) as res: data = await res.json() if use_latest_release: + if 'tag_name' not in data: + logger.error('%s: No tag found in upstream repository.', name) + return version = data['tag_name'] elif use_max_tag: data = [tag["name"] for tag in data if tag["name"] not in ignored_tags] data.sort(key=sort_version_key) + if not len(data): + logger.error('%s: No tag found in upstream repository.', name) + return version = data[-1] else: # YYYYMMDD.HHMMSS