mirror of
https://github.com/lilydjwg/nvchecker
synced 2024-12-12 01:35:49 +00:00
Merge pull request #65 from felixonmars/handle-exception
Handle exception for no-tag situation
This commit is contained in:
commit
48c394b693
@ -2,6 +2,7 @@
|
|||||||
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
|
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
from . import session
|
from . import session
|
||||||
from ..sortversion import sort_version_keys
|
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_LATEST_RELEASE = 'https://api.github.com/repos/%s/releases/latest'
|
||||||
GITHUB_MAX_TAG = 'https://api.github.com/repos/%s/tags'
|
GITHUB_MAX_TAG = 'https://api.github.com/repos/%s/tags'
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
async def get_version(name, conf):
|
async def get_version(name, conf):
|
||||||
repo = conf.get('github')
|
repo = conf.get('github')
|
||||||
br = conf.get('branch', 'master')
|
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:
|
async with session.get(url, headers=headers, **kwargs) as res:
|
||||||
data = await res.json()
|
data = await res.json()
|
||||||
if use_latest_release:
|
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']
|
version = data['tag_name']
|
||||||
elif use_max_tag:
|
elif use_max_tag:
|
||||||
data = [tag["name"] for tag in data if tag["name"] not in ignored_tags]
|
data = [tag["name"] for tag in data if tag["name"] not in ignored_tags]
|
||||||
data.sort(key=sort_version_key)
|
data.sort(key=sort_version_key)
|
||||||
|
if not len(data):
|
||||||
|
logger.error('%s: No tag found in upstream repository.', name)
|
||||||
|
return
|
||||||
version = data[-1]
|
version = data[-1]
|
||||||
else:
|
else:
|
||||||
# YYYYMMDD.HHMMSS
|
# YYYYMMDD.HHMMSS
|
||||||
|
Loading…
Reference in New Issue
Block a user