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

[develop2] allow --no-remotes to force temporal disabling of remotes #12808

Merged
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
7 changes: 5 additions & 2 deletions conan/cli/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ def _add_common_install_arguments(parser, build_help, update_help=None):
if build_help:
parser.add_argument("-b", "--build", action="append", help=build_help)

parser.add_argument("-r", "--remote", action="append", default=None,
help='Look in the specified remote or remotes server')
group = parser.add_mutually_exclusive_group()
group.add_argument("-r", "--remote", action="append", default=None,
help='Look in the specified remote or remotes server')
group.add_argument("-nr", "--no-remote", action="store_true",
help='Do not use remote, resolve exclusively in the cache')

if not update_help:
update_help = ("Will check the remote and in case a newer version and/or revision of "
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def build(conan_api, parser, *args):
cwd = os.getcwd()
path = conan_api.local.get_conanfile_path(args.path, cwd, py=True)
folder = os.path.dirname(path)
remotes = conan_api.remotes.list(args.remote)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []

lockfile = conan_api.lockfile.get_lockfile(lockfile=args.lockfile,
conanfile_path=path,
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def create(conan_api, parser, *args):
conanfile_path=path,
cwd=cwd,
partial=args.lockfile_partial)
remotes = conan_api.remotes.list(args.remote)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []
profile_host, profile_build = conan_api.profiles.get_profiles_from_args(args)

out = ConanOutput()
Expand Down
9 changes: 6 additions & 3 deletions conan/cli/commands/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ def export(conan_api, parser, *args):
Export recipe to the Conan package cache
"""
common_args_export(parser)
parser.add_argument("-r", "--remote", action="append", default=None,
help='Look in the specified remote or remotes server')
group = parser.add_mutually_exclusive_group()
group.add_argument("-r", "--remote", action="append", default=None,
help='Look in the specified remote or remotes server')
group.add_argument("-nr", "--no-remote", action="store_true",
help='Do not use remote, resolve exclusively in the cache')
parser.add_argument("-l", "--lockfile", action=OnceArgument,
help="Path to a lockfile.")
parser.add_argument("--lockfile-out", action=OnceArgument,
Expand All @@ -35,7 +38,7 @@ def export(conan_api, parser, *args):

cwd = os.getcwd()
path = conan_api.local.get_conanfile_path(args.path, cwd, py=True)
remotes = conan_api.remotes.list(args.remote)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []
lockfile = conan_api.lockfile.get_lockfile(lockfile=args.lockfile,
conanfile_path=path,
cwd=cwd,
Expand Down
4 changes: 2 additions & 2 deletions conan/cli/commands/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def graph_build_order(conan_api, parser, subparser, *args):
path = conan_api.local.get_conanfile_path(args.path, cwd, py=None) if args.path else None

# Basic collaborators, remotes, lockfile, profiles
remotes = conan_api.remotes.list(args.remote)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []
lockfile = conan_api.lockfile.get_lockfile(lockfile=args.lockfile,
conanfile_path=path,
cwd=cwd,
Expand Down Expand Up @@ -132,7 +132,7 @@ def graph_info(conan_api, parser, subparser, *args):
path = conan_api.local.get_conanfile_path(args.path, cwd, py=None) if args.path else None

# Basic collaborators, remotes, lockfile, profiles
remotes = conan_api.remotes.list(args.remote)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []
lockfile = conan_api.lockfile.get_lockfile(lockfile=args.lockfile,
conanfile_path=path,
cwd=cwd,
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def install(conan_api, parser, *args):
output_folder = None

# Basic collaborators, remotes, lockfile, profiles
remotes = conan_api.remotes.list(args.remote)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []
lockfile = conan_api.lockfile.get_lockfile(lockfile=args.lockfile,
conanfile_path=path,
cwd=cwd,
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def lock_create(conan_api, parser, subparser, *args):

cwd = os.getcwd()
path = conan_api.local.get_conanfile_path(args.path, cwd, py=None) if args.path else None
remotes = conan_api.remotes.list(args.remote)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []
lockfile = conan_api.lockfile.get_lockfile(lockfile=args.lockfile, conanfile_path=path,
cwd=cwd, partial=True)
profile_host, profile_build = conan_api.profiles.get_profiles_from_args(args)
Expand Down
2 changes: 1 addition & 1 deletion conan/cli/commands/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test(conan_api, parser, *args):
conanfile_path=path,
cwd=cwd,
partial=args.lockfile_partial)
remotes = conan_api.remotes.list(args.remote)
remotes = conan_api.remotes.list(args.remote) if not args.no_remote else []
profile_host, profile_build = conan_api.profiles.get_profiles_from_args(args)

out = ConanOutput()
Expand Down
11 changes: 11 additions & 0 deletions conans/test/integration/command/install/install_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,17 @@ def test_install_disabled_remote(client):
assert "ERROR: Remote 'default' can't be found or is disabled" in client.out


def test_install_no_remotes(client):
client.save({"conanfile.py": GenConanfile("pkg", "0.1")})
client.run("create .")
client.run("upload * --confirm -r default")
client.run("remove * -c")
client.run("install --requires=pkg/0.1 -nr", assert_error=True)
assert "ERROR: Package 'pkg/0.1' not resolved: No remote defined" in client.out
client.run("install --requires=pkg/0.1") # this works without issue
client.run("install --requires=pkg/0.1 -nr") # and now this too, pkg in cache


def test_install_skip_disabled_remote():
client = TestClient(servers=OrderedDict({"default": TestServer(),
"server2": TestServer(),
Expand Down