Skip to content

Commit

Permalink
Fix some regressions of new features, for #2
Browse files Browse the repository at this point in the history
  • Loading branch information
dvershinin committed Jun 12, 2019
1 parent aefa547 commit 2db09e9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
39 changes: 28 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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).
Expand Down
7 changes: 6 additions & 1 deletion lastversion/lastversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions tests/test_lastversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 2db09e9

Please sign in to comment.