added path to github source

This commit is contained in:
Jingbei Li 2019-01-28 16:53:42 +08:00
parent 2f24822c88
commit 620c7a89cd
3 changed files with 16 additions and 1 deletions

View file

@ -249,6 +249,9 @@ github
branch
Which branch to track? Default: ``master``.
path
Only commits containing this file path will be returned.
use_latest_release
Set this to ``true`` to check for the latest release on GitHub. An annotated
tag creates a "release" on GitHub. It's not the same with git tags, which

View file

@ -4,6 +4,7 @@
import os
import re
import time
from urllib.parse import urlencode
from functools import partial
import structlog
@ -26,6 +27,7 @@ async def get_version(name, conf, **kwargs):
async def get_version_real(name, conf, **kwargs):
repo = conf.get('github')
br = conf.get('branch')
path = conf.get('path')
use_latest_release = conf.getboolean('use_latest_release', False)
use_max_tag = conf.getboolean('use_max_tag', False)
include_tags_pattern = conf.get("include_tags_pattern", "")
@ -37,8 +39,12 @@ async def get_version_real(name, conf, **kwargs):
url = GITHUB_MAX_TAG % repo
else:
url = GITHUB_URL % repo
parameters = {}
if br:
url += '?sha=' + br
parameters['sha'] = br
if path:
parameters['path'] = path
url += '?' + urlencode(parameters)
headers = {
'Accept': 'application/vnd.github.quicksilver-preview+json',
'User-Agent': 'lilydjwg/nvchecker',

View file

@ -23,6 +23,12 @@ async def test_github_max_tag(get_version):
async def test_github_max_tag_with_ignored_tags(get_version):
assert await get_version("example", {"github": "harry-sanabria/ReleaseTestRepo", "use_max_tag": 1, "ignored_tags": "second_release release3"}) == "first_release"
async def test_github_with_path(get_version):
assert await get_version("example", {"github": "petronny/ReleaseTestRepo", "path": "test_directory"}) == "20140122.012101"
async def test_github_with_path_and_branch(get_version):
assert await get_version("example", {"github": "petronny/ReleaseTestRepo", "branch": "test", "path": "test_directory/test_directory"}) == "20190128.113201"
async def test_github_max_tag_with_include(get_version):
version = await get_version("example", {
"github": "EFForg/https-everywhere",