From e64b2e132e5b2dedb1c9ddad830c1680d7babb61 Mon Sep 17 00:00:00 2001 From: Noah Massey Date: Mon, 6 Jun 2022 16:52:44 -0400 Subject: [PATCH] Update conans/test/unittests/tools/scm/test_git_get_commit.py - Test that submodules work as subfolders --- .../tools/scm/test_git_get_commit.py | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/conans/test/unittests/tools/scm/test_git_get_commit.py b/conans/test/unittests/tools/scm/test_git_get_commit.py index 59b43e85955..ffe7fe13058 100644 --- a/conans/test/unittests/tools/scm/test_git_get_commit.py +++ b/conans/test/unittests/tools/scm/test_git_get_commit.py @@ -35,11 +35,17 @@ def test_change_branch_in_root_commit(): def test_multi_folder_repo(): c = TestClient() conanfile = MockConanfile({}) - c.save({"lib_a/conanfile.py": ""}) + c.save({"conanfile.py": ""}) c.run_command("git init .") c.run_command('git config user.name myname') c.run_command('git config user.email myname@mycompany.com') c.run_command("git add .") + c.run_command('git commit -m "Initial commit"') + c.run_command('git clone . source_subfolder') + c.run_command('git submodule add ../ source_subfolder') + c.run_command('git commit -m "submodule commit"') + c.save({"lib_a/conanfile.py": ""}) + c.run_command("git add .") c.run_command('git commit -m "lib_a commit"') c.save({"lib_b/conanfile.py": ""}) c.run_command("git add .") @@ -61,11 +67,15 @@ def test_multi_folder_repo(): git = Git(conanfile, folder=os.path.join(c.current_folder, "lib_c")) commit_libC = git.get_commit() + # Git object for submodule + git = Git(conanfile, folder=os.path.join(c.current_folder, "source_subfolder")) + commit_sub = git.get_commit() + git = Git(conanfile, folder=c.current_folder) commit_root = git.get_commit() # All different - assert len({commit_libA, commit_libB, commit_libC, commit_root}) == 4 + assert len({commit_libA, commit_libB, commit_libC, commit_sub, commit_root}) == 5 c.run_command("git rev-parse HEAD") commit_real = str(c.out).splitlines()[0] @@ -78,12 +88,20 @@ def test_multi_folder_repo(): git = Git(conanfile, folder="./lib_b") rel_commit_libB = git.get_commit() + git = Git(conanfile, folder="source_subfolder") + rel_commit_sub1 = git.get_commit() + + git = Git(conanfile, folder="./source_subfolder") + rel_commit_sub2 = git.get_commit() + # this is folder default git = Git(conanfile, folder=".") rel_commit_root = git.get_commit() assert rel_commit_libA == commit_libA assert rel_commit_libB == commit_libB + assert rel_commit_sub1 == commit_sub + assert rel_commit_sub2 == commit_sub assert rel_commit_root == commit_root # New commit in A