Skip to content

Commit e1cb06d

Browse files
authored
add warning for local-recipes-idnex used with revisions (#17819)
1 parent c434d60 commit e1cb06d

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

conans/client/rest_client_local_recipe_index.py

+3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ def get_latest_package_reference(self, pref, headers):
138138
def get_recipe_revision_reference(self, ref):
139139
new_ref = self._export_recipe(ref)
140140
if new_ref != ref:
141+
ConanOutput().warning(f"A specific revision '{ref.repr_notime()}' was requested, but it "
142+
"doesn't match the current available revision in source. The "
143+
"local-recipes-index can't provide a specific revision")
141144
raise RecipeNotFoundException(ref)
142145
return new_ref
143146

test/integration/remote/test_local_recipes_index.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,23 @@ class Zlib(ConanFile):
332332
c.run("install --requires=zlib/[*] --build missing", assert_error=True)
333333
assert "NameError: name 'ConanFile' is not defined" in c.out
334334

335+
def test_require_revision(self):
336+
# https://github.com/conan-io/conan/issues/17814
337+
folder = temp_folder()
338+
recipes_folder = os.path.join(folder, "recipes")
339+
zlib_config = textwrap.dedent("""
340+
versions:
341+
"1.2.11":
342+
folder: all
343+
""")
344+
save_files(recipes_folder,
345+
{"zlib/config.yml": zlib_config,
346+
"zlib/all/conanfile.py": str(GenConanfile("zlib"))})
347+
c = TestClient(light=True)
348+
c.run(f"remote add local '{folder}'")
349+
c.run("install --requires=zlib/1.2.11#rev1", assert_error=True)
350+
assert "A specific revision 'zlib/1.2.11#rev1' was requested" in c.out
351+
335352

336353
class TestPythonRequires:
337354
@pytest.fixture(scope="class")
@@ -361,6 +378,7 @@ def test_install(self, c3i_pyrequires_folder):
361378
assert "pyreq/1.0#a0d63ca853edefa33582a24a1bb3c75f - Downloaded (local)" in c.out
362379
assert "pkg/1.0: Created package" in c.out
363380

381+
364382
class TestUserChannel:
365383
@pytest.fixture(scope="class")
366384
def c3i_user_channel_folder(self):
@@ -373,8 +391,8 @@ def c3i_user_channel_folder(self):
373391
"2.0":
374392
folder: other
375393
""")
376-
pkg = str(GenConanfile("pkg").with_class_attribute("user='myuser'")\
377-
.with_class_attribute("channel='mychannel'"))
394+
pkg = str(GenConanfile("pkg").with_class_attribute("user='myuser'")
395+
.with_class_attribute("channel='mychannel'"))
378396
save_files(recipes_folder,
379397
{"pkg/config.yml": config,
380398
"pkg/all/conanfile.py": pkg,

0 commit comments

Comments
 (0)