diff --git a/README.md b/README.md index ab66387f..1f3dc7a4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Or otherwise require getting latest version in your automation scripts. That repository specifically, is a good example. Because using only API on it will yield an ancient release: - lastversion --nosniff apache/incubator-pagespeed-ngx #> 1.9.32.10 + lastversion --nosniff apache/incubator-pagespeed-ngx #> 1.9.32.10 Why is because at some point the maintainers of the repository did a formal UI release, but later used the standard approach. @@ -35,18 +35,35 @@ Or otherwise require getting latest version in your automation scripts. ## Usage - ``` - usage: lastversion [-h] [--nosniff] [--novalidate] R - - Get latest release from GitHub. + Typically, you would just pass the repository URL (or repo owner/name to it) as the only argument, e.g.: - positional arguments: - R GitHub repository in format owner/name + lastversion https://github.com/gperftools/gperftools + +Equivalently accepted invocation with same output is: + + lastversion gperftools/gperftools + +For more options to control output or behavior, see `--help` output: - optional arguments: - -h, --help show this help message and exit - --nosniff - --novalidate + ``` +usage: lastversion [-h] [--nosniff] [--novalidate] [--pre] [--verbose] + [--format {json,version}] [--version] + REPO + +Get latest release from GitHub. + +positional arguments: + REPO GitHub repository in format owner/name + +optional arguments: + -h, --help show this help message and exit + --nosniff Only use GitHub API, no HTML parsing (worse) + --novalidate + --pre Include pre-releases in potential versions + --verbose + --format {json,version} + Output format + --version show program's version number and exit ``` The `--nosniff` will disable the magic and only API will be used (yuck). diff --git a/lastversion/lastversion.py b/lastversion/lastversion.py index 165e8845..cfef4f13 100644 --- a/lastversion/lastversion.py +++ b/lastversion/lastversion.py @@ -102,7 +102,12 @@ def latest(repo, sniff=True, validate=True, format='version', pre=False): the_version = sanitize_version(the_version) # trust this to be the release and validate below version = the_version - description = r.find(class_='markdown-body').text + if format == 'json': + description = r.find(class_='markdown-body') + if not description: + description = r.find(class_='commit-desc') + if description: + description = description.text break r = r.find_next_sibling(class_='release-entry', recursive=False) diff --git a/tests/test_lastversion.py b/tests/test_lastversion.py index 2770678f..b8ea3998 100644 --- a/tests/test_lastversion.py +++ b/tests/test_lastversion.py @@ -61,3 +61,11 @@ def test_grafana(): output = lastversion.latest(repo) assert version.parse(output) >= version.parse("6.2.2") + + +def test_roer(): + repo = "spinnaker/roer" + + output = lastversion.latest(repo) + + assert version.parse(output) >= version.parse("0.11.3")