Skip to content

Commit

Permalink
Merge 8356453 into 68c53a4
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Dec 7, 2019
2 parents 68c53a4 + 8356453 commit 0defaff
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .python-version
@@ -0,0 +1,2 @@
3.7.5
2.7.14
2 changes: 1 addition & 1 deletion .verchew.ini
Expand Up @@ -16,7 +16,7 @@ version = Python 3
[Poetry]

cli = poetry
version = 0.12
version = 1.0 || 0.12

[Graphviz]

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

- Removed `versions` in favor of `version` option.
- Removed `|` in favor of `||` for checking multiple versions.
- Added support for matching **any** version when `version` is not specified.

# 2.0.1 (2019-10-13)

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -28,8 +28,8 @@ run: install
poetry run python $(PACKAGE)/__main__.py

.PHONY: demo ## Run the example
demo: install
make doctor -C examples
demo:
cd examples && make doctor

# SYSTEM DEPENDENCIES ##########################################################

Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile
Expand Up @@ -5,4 +5,4 @@ all: doctor
doctor:
@ echo
@ echo "$$ verchew"
@ PATH=bin:$(PATH) ../verchew/script.py
@ ../verchew/script.py
14 changes: 11 additions & 3 deletions verchew/script.py
Expand Up @@ -212,7 +212,7 @@ def check_dependencies(config):

for pattern in settings['patterns']:
if match_version(pattern, output):
show(_("~") + " MATCHED: {0}".format(pattern))
show(_("~") + " MATCHED: {0}".format(pattern or "<anything>"))
success.append(_("~"))
break
else:
Expand All @@ -222,9 +222,14 @@ def check_dependencies(config):
else:
if QUIET:
print(
"Unmatched {0} version: {1}".format(name, settings['version'])
"Unmatched {0} version: {1}".format(
name, settings['version'] or "<anything>"
)
)
show(_("x") + " EXPECTED: {0}".format(settings['version']))
show(
_("x")
+ " EXPECTED: {0}".format(settings['version'] or "<anything>")
)
success.append(_("x"))
if settings.get('message'):
show(_("*") + " MESSAGE: {0}".format(settings['message']))
Expand All @@ -251,6 +256,9 @@ def get_version(program, argument=None):


def match_version(pattern, output):
if "not found" in output:
return False

regex = pattern.replace('.', r'\.') + r'(\b|/)'

log.debug("Matching %s: %s", regex, output)
Expand Down
3 changes: 3 additions & 0 deletions verchew/tests/test_script.py
Expand Up @@ -148,6 +148,9 @@ def when_match_with_slug_inside_path():
match_version(".pyenv", "Users/foobar/.pyenv/versions/2.7.14/bin/python")
) == True

def when_mismatch_with_missing_program():
expect(match_version("", "program not found")) == False


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

0 comments on commit 0defaff

Please sign in to comment.