Skip to content

Commit

Permalink
Update conans/test/unittests/tools/scm/test_git_get_commit.py
Browse files Browse the repository at this point in the history
- Test that submodules work as subfolders
  • Loading branch information
nmasseyKM committed Jun 6, 2022
1 parent 57f879a commit e64b2e1
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions conans/test/unittests/tools/scm/test_git_get_commit.py
Expand Up @@ -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 .")
Expand All @@ -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]
Expand All @@ -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
Expand Down

0 comments on commit e64b2e1

Please sign in to comment.