From c150b77b61c9b02c12aaa6d237e549ba85893626 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Wed, 7 Feb 2018 18:54:09 +0800 Subject: [PATCH] github: don't use master as default branch --- nvchecker/__init__.py | 4 ++-- nvchecker/source/github.py | 8 +++++--- tests/test_github.py | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/nvchecker/__init__.py b/nvchecker/__init__.py index b32f656..f56f1c2 100644 --- a/nvchecker/__init__.py +++ b/nvchecker/__init__.py @@ -1,4 +1,4 @@ # MIT licensed -# Copyright (c) 2013-2017 lilydjwg , et al. +# Copyright (c) 2013-2018 lilydjwg , et al. -__version__ = '1.0' +__version__ = '1.1dev' diff --git a/nvchecker/source/github.py b/nvchecker/source/github.py index 77c2a69..c7deb16 100644 --- a/nvchecker/source/github.py +++ b/nvchecker/source/github.py @@ -7,7 +7,7 @@ import logging from . import session from ..sortversion import sort_version_keys -GITHUB_URL = 'https://api.github.com/repos/%s/commits?sha=%s' +GITHUB_URL = 'https://api.github.com/repos/%s/commits' GITHUB_LATEST_RELEASE = 'https://api.github.com/repos/%s/releases/latest' GITHUB_MAX_TAG = 'https://api.github.com/repos/%s/tags' @@ -15,7 +15,7 @@ logger = logging.getLogger(__name__) async def get_version(name, conf): repo = conf.get('github') - br = conf.get('branch', 'master') + br = conf.get('branch') use_latest_release = conf.getboolean('use_latest_release', False) use_max_tag = conf.getboolean('use_max_tag', False) ignored_tags = conf.get("ignored_tags", "").split() @@ -25,7 +25,9 @@ async def get_version(name, conf): elif use_max_tag: url = GITHUB_MAX_TAG % repo else: - url = GITHUB_URL % (repo, br) + url = GITHUB_URL % repo + if br: + url += '?sha=' + br headers = { 'Accept': 'application/vnd.github.quicksilver-preview+json', 'User-Agent': 'lilydjwg/nvchecker', diff --git a/tests/test_github.py b/tests/test_github.py index e5195f2..42010ed 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -10,6 +10,9 @@ pytestmark = [pytest.mark.asyncio, async def test_github(get_version): assert await get_version("example", {"github": "harry-sanabria/ReleaseTestRepo"}) == "20140122.012101" +async def test_github_default_not_master(get_version): + assert await get_version("example", {"github": "repos/MariaDB"}) is not None + async def test_github_latest_release(get_version): assert await get_version("example", {"github": "harry-sanabria/ReleaseTestRepo", "use_latest_release": 1}) == "release3"