From d09ae5b9294832372ef99b70a7c7559b0be38d57 Mon Sep 17 00:00:00 2001 From: Nikita Akatyev <48411360+BobIsOnFire@users.noreply.github.com> Date: Wed, 19 Jul 2023 14:14:03 +0200 Subject: [PATCH] revision_mode = 'scm_folder': Only check if conanfile_path is dirty (#14330) --- conans/client/cmd/export.py | 4 ++-- conans/test/functional/command/export_test.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/conans/client/cmd/export.py b/conans/client/cmd/export.py index fd9a90ec7ec..c92b58fd917 100644 --- a/conans/client/cmd/export.py +++ b/conans/client/cmd/export.py @@ -93,9 +93,9 @@ def _calc_revision(scoped_output, path, manifest, revision_mode): if revision_mode == "hash": revision = manifest.summary_hash else: + f = '-- "."' if revision_mode == "scm_folder" else "" try: with chdir(path): - f = '-- "."' if revision_mode == "scm_folder" else "" revision = check_output_runner(f'git rev-list HEAD -n 1 --full-history {f}').strip() except Exception as exc: error_msg = "Cannot detect revision using '{}' mode from repository at " \ @@ -103,7 +103,7 @@ def _calc_revision(scoped_output, path, manifest, revision_mode): raise ConanException("{}: {}".format(error_msg, exc)) with chdir(path): - if bool(check_output_runner('git status -s').strip()): + if bool(check_output_runner(f'git status -s {f}').strip()): raise ConanException("Can't have a dirty repository using revision_mode='scm' and doing" " 'conan export', please commit the changes and run again.") diff --git a/conans/test/functional/command/export_test.py b/conans/test/functional/command/export_test.py index 1f1806d81cb..806d86c7a38 100644 --- a/conans/test/functional/command/export_test.py +++ b/conans/test/functional/command/export_test.py @@ -47,6 +47,11 @@ def test_revision_mode_scm_subfolder(self): t.run(f"export pkgb --name=pkgb --version=0.1") assert t.exported_recipe_revision() == commit_b + # if pkgb is dirty, we should still be able to correctly create pkga in 'scm_folder' mode + t.save({"pkgb/conanfile.py": conanfile + "\n#new comment"}) + t.run(f"export pkga --name=pkga --version=0.1") + assert t.exported_recipe_revision() == commit + def test_auto_revision_without_commits(self): """If we have a repo but without commits, it has to fail when the revision_mode=scm""" t = TestClient()