Skip to content

Commit

Permalink
Merge pull request #16 from bincrafters/hotfix/506
Browse files Browse the repository at this point in the history
#506 Fix remote address format
  • Loading branch information
uilianries authored Jan 16, 2019
2 parents d6ff9e5 + 1d7320e commit c3f3344
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bincrafters/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.17.6'
__version__ = '0.17.7'
13 changes: 10 additions & 3 deletions bincrafters/build_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
32 changes: 31 additions & 1 deletion tests/test_package_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
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

0 comments on commit c3f3344

Please sign in to comment.