Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use center2.conan.io as new default remote and warn about having the old one. #17284

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conan/api/subapi/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def user_auth(self, remote: Remote, with_user=False):

def _load(remotes_file):
if not os.path.exists(remotes_file):
remote = Remote(CONAN_CENTER_REMOTE_NAME, "https://center.conan.io", True, False)
remote = Remote(CONAN_CENTER_REMOTE_NAME, "https://center2.conan.io", True, False)
_save(remotes_file, [remote])
return [remote]

Expand Down Expand Up @@ -313,7 +313,7 @@ def _validate_url(url):
if url.startswith("https://conan.io/center"):
raise ConanException("Wrong ConanCenter remote URL. You are adding the web "
"https://conan.io/center the correct remote API is "
"https://center.conan.io")
"https://center2.conan.io")
address = urlparse(url)
if not all([address.scheme, address.netloc]):
out.warning(f"The URL '{url}' is invalid. It must contain scheme and hostname.")
Expand Down
15 changes: 15 additions & 0 deletions conan/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def run(self, *args):

try:
command.run(self._conan_api, args[0][1:])
_warn_frozen_center(self._conan_api)
memsharded marked this conversation as resolved.
Show resolved Hide resolved
except Exception as e:
# must be a local-import to get updated value
if ConanOutput.level_allowed(LEVEL_TRACE):
Expand Down Expand Up @@ -245,6 +246,20 @@ def _warn_python_version():
ConanOutput().warning("*" * 80, warn_tag="deprecated")


def _warn_frozen_center(conan_api):
remotes = conan_api.remotes.list()
for r in remotes:
if r.url == "https://center.conan.io":
ConanOutput().warning(
"The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'. \n"
"Starting from Conan 2.9.2, the default remote is 'center2.conan.io'. \n"
"It is recommended to update to the new remote using the following command:\n"
f"'conan remote update {r.name} --url=\"https://center2.conan.io\"'",
warn_tag="deprecated"
)
break


def main(args):
""" main entry point of the conan application, using a Command to
parse parameters
Expand Down
29 changes: 26 additions & 3 deletions test/integration/command/remote_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,34 @@ def test_add_wrong_conancenter():
c = TestClient(light=True)
c.run("remote add whatever https://conan.io/center", assert_error=True)
assert "Wrong ConanCenter remote URL. You are adding the web https://conan.io/center" in c.out
assert "the correct remote API is https://center.conan.io" in c.out
c.run("remote add conancenter https://center.conan.io")
assert "the correct remote API is https://center2.conan.io" in c.out
c.run("remote add conancenter https://center2.conan.io")
c.run("remote update conancenter --url=https://conan.io/center", assert_error=True)
assert "Wrong ConanCenter remote URL. You are adding the web https://conan.io/center" in c.out
assert "the correct remote API is https://center.conan.io" in c.out
assert "the correct remote API is https://center2.conan.io" in c.out


def test_using_frozen_center():
""" If the legacy center.conan.io is in the remote list warn about it.
"""
c = TestClient(light=True)
c.run("remote add whatever https://center.conan.io")
assert "The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'." in c.out
assert 'conan remote update whatever --url="https://center2.conan.io"' in c.out

c.run("remote list")
assert "The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'." in c.out

c.run("remote remove whatever")

c.run("remote add conancenter https://center2.conan.io")
assert "The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'." not in c.out

c.run("remote list")
assert "The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'." not in c.out

c.run("remote update conancenter --url=https://center.conan.io")
assert "The remote 'https://center.conan.io' is now frozen and has been replaced by 'https://center2.conan.io'." in c.out


def test_wrong_remotes_json_file():
Expand Down