Skip to content

Commit

Permalink
Merge pull request #90 from jacebrowning/handle-no-output
Browse files Browse the repository at this point in the history
Fix handling of programs with no output
  • Loading branch information
jacebrowning authored Jun 13, 2023
2 parents 345a3cf + 49ddc6d commit ccb6117
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"DIRENV",
"printenv",
"pyenv",
"USERPROFILE"
"USERPROFILE",
"verchewrc"
]
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Release Notes

## 3.4.1 (2022-06-13)

- Fixed handling of programs with no output.

## 3.4 (2023-06-03)

- Added support for matching version not in the first line of output.

## 3.3 (2022-04-18)

- Added a `verchew-wrapper` alongside the vendored script to support systems not following [PEP 394](https://peps.python.org/pep-0394/).
Expand Down
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ VIRTUAL_ENV ?= .venv
# MAIN TASKS ##################################################################

.PHONY: all
all: install

.PHONY: ci
ci: format check test mkdocs ## Run all tasks that determine CI status
all: format check test mkdocs ## Run all tasks that determine CI status

.PHONY: dev
dev: install .clean-test ## Continuously run all CI tasks when files chanage
Expand Down Expand Up @@ -204,7 +201,7 @@ clean-all: clean
# HELP ########################################################################

.PHONY: help
help: all
help: install
@ grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]

name = "verchew"
version = "3.4" # also update verchew/script.py
version = "3.4.1" # also update verchew/script.py
description = "System dependency version checker."

license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions verchew/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import configparser
from urllib.request import urlretrieve

__version__ = '3.4'
__version__ = '3.4.1'

SCRIPT_URL = (
"https://raw.githubusercontent.com/jacebrowning/verchew/main/verchew/script.py"
Expand Down Expand Up @@ -311,7 +311,7 @@ def get_version(program, argument=None):

def match_version(pattern, output):
lines = output.splitlines()
if "not found" in lines[0]:
if not lines or "not found" in lines[0]:
return False

regex = pattern.replace('.', r'\.') + r'(\b|/)'
Expand Down
3 changes: 3 additions & 0 deletions verchew/tests/test_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ def when_mismatch_with_missing_program():
def when_match_with_multiple_lines():
expect(match_version("1.2", "Foobar\nVersion 1.2.3")) == True

def when_mismatch_with_no_output():
expect(match_version("1.2.3", "")) == False


def describe_format():
def default():
Expand Down

0 comments on commit ccb6117

Please sign in to comment.