diff --git a/bincrafters/__init__.py b/bincrafters/__init__.py index 98e595c..f7d1e3e 100644 --- a/bincrafters/__init__.py +++ b/bincrafters/__init__.py @@ -1 +1 @@ -__version__ = '0.17.6' +__version__ = '0.17.7' diff --git a/bincrafters/build_shared.py b/bincrafters/build_shared.py index e654593..d745ec7 100644 --- a/bincrafters/build_shared.py +++ b/bincrafters/build_shared.py @@ -101,14 +101,21 @@ def get_user_repository(username, repository_name): def get_conan_upload(username): + upload = os.getenv("CONAN_UPLOAD") + if upload: + return upload.split('@') if '@' in upload else upload + repository_name = os.getenv("BINTRAY_REPOSITORY", "public-conan") - return os.getenv("CONAN_UPLOAD", get_user_repository(username, repository_name)) + return get_user_repository(username, repository_name) def get_conan_remotes(username): + remotes = os.getenv("CONAN_REMOTES") + if remotes: + return [remotes.split('@')] if '@' in remotes else [remotes] + # While redundant, this moves upload remote to position 0. remotes = [get_conan_upload(username)] - # Add bincrafters repository for other users, e.g. if the package would # require other packages from the bincrafters repo. bincrafters_user = "bincrafters" @@ -136,7 +143,7 @@ def get_builder(build_policy=None): username, channel, version, login_username = get_conan_vars() reference = "{0}/{1}".format(name, version) upload = get_conan_upload(username) - remotes = os.getenv("CONAN_REMOTES", get_conan_remotes(username)) + remotes = get_conan_remotes(username) upload_when_stable = get_upload_when_stable() stable_branch_pattern = os.getenv("CONAN_STABLE_BRANCH_PATTERN", "stable/*") archs = get_archs() diff --git a/tests/test_package_tools.py b/tests/test_package_tools.py index 3d4b909..f2e7c57 100644 --- a/tests/test_package_tools.py +++ b/tests/test_package_tools.py @@ -38,6 +38,20 @@ def set_upload_when_stable_false(): del os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] +@pytest.fixture() +def set_upload_address(): + os.environ["CONAN_UPLOAD"] = "https://api.bintray.com/conan/foo/bar@False@remotefoo" + yield + del os.environ["CONAN_UPLOAD"] + + +@pytest.fixture() +def set_remote_address(): + os.environ["CONAN_REMOTES"] = "https://api.bintray.com/conan/foo/bar@False@remotefoo" + yield + del os.environ["CONAN_REMOTES"] + + def test_build_template_boost_default(): builder = build_template_boost_default.get_builder() @@ -160,4 +174,20 @@ def test_upload_only_when_stable_builder(set_upload_when_stable_false): def test_upload_only_when_stable_header_only(set_upload_when_stable_false): builder = build_template_header_only.get_builder() - assert False == builder.upload_only_when_stable \ No newline at end of file + assert False == builder.upload_only_when_stable + + +def test_format_upload(set_upload_address): + builder = build_template_default.get_builder() + assert "remotefoo" == builder.remotes_manager.upload_remote_name + assert "remotefoo" == builder.remotes_manager._upload.name + assert "https://api.bintray.com/conan/foo/bar" == builder.remotes_manager._upload.url + assert 'False' == builder.remotes_manager._upload.use_ssl + + +def test_format_remote(set_remote_address): + builder = build_template_default.get_builder() + remote = builder.remotes_manager._remotes[0] + assert "remotefoo" == remote.name + assert "https://api.bintray.com/conan/foo/bar" == remote.url + assert 'False' == remote.use_ssl