From b0595e418f65bbf5d236e1ada3921d0cd5be8d4e Mon Sep 17 00:00:00 2001 From: Philipp Hanslovsky Date: Wed, 14 Aug 2019 13:30:31 -0400 Subject: [PATCH 1/2] Add failing test to reproduce #46 --- jgo/jgo.py | 1 + tests/test_shortcut_expansion.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/test_shortcut_expansion.py diff --git a/jgo/jgo.py b/jgo/jgo.py index 5d71243..0adae45 100644 --- a/jgo/jgo.py +++ b/jgo/jgo.py @@ -367,6 +367,7 @@ def split_endpoint_string(endpoint_string): return endpoint_strings def endpoints_from_strings(endpoint_strings, shortcuts={}): + _logger.debug('Creating endpoints from strings %s with shortcuts %s', endpoint_strings, shortcuts) return [Endpoint.parse_endpoint(expand_coordinate(ep, shortcuts=shortcuts)) for ep in endpoint_strings] def coordinates_from_endpoints(endpoints): diff --git a/tests/test_shortcut_expansion.py b/tests/test_shortcut_expansion.py new file mode 100644 index 0000000..9ce95ca --- /dev/null +++ b/tests/test_shortcut_expansion.py @@ -0,0 +1,29 @@ +import jgo +import pathlib +import tempfile +import unittest + +import logging +_logger = logging.getLogger(__name__) + +class ExpansionTest(unittest.TestCase): + + def test_groovy_issue_46(self): + shortcuts = {'groovy': 'org.codehaus.groovy:groovy-groovysh:org.codehaus.groovy.tools.shell.Main+commons-cli:commons-cli:1.3.1'} + + tmp_dir = tempfile.mkdtemp(prefix='jgo-test-cache-dir') + m2_repo = pathlib.Path.home() / '.m2' / 'repository' + + primary_endpoint, workspace = jgo.resolve_dependencies( + 'groovy', + cache_dir = tmp_dir, + m2_repo = m2_repo, + update_cache = True, + shortcuts = shortcuts, + verbose = 1) + _logger.debug('Got primary_endpoint %s and workspace %s', primary_endpoint, workspace) + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + unittest.main() \ No newline at end of file From 2f1c490010d12d2a221b1a5caca337e6405f1bf8 Mon Sep 17 00:00:00 2001 From: Philipp Hanslovsky Date: Tue, 20 Aug 2019 14:11:55 -0400 Subject: [PATCH 2/2] Match shortcuts to endpoint if split by '+' --- jgo/jgo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jgo/jgo.py b/jgo/jgo.py index 0adae45..0b1b78f 100644 --- a/jgo/jgo.py +++ b/jgo/jgo.py @@ -231,7 +231,7 @@ def find_endpoint(argv, shortcuts={}): pattern = re.compile('.*https?://.*') indices = [] for index, arg in enumerate(argv): - if arg in shortcuts or (Endpoint.is_endpoint(arg) and not pattern.match(arg)): + if any(a in shortcuts for a in arg.split('+')) or (Endpoint.is_endpoint(arg) and not pattern.match(arg)): indices.append(index) return -1 if len(indices) == 0 else indices[-1]