@@ -63,6 +63,32 @@ def test_clone_to_directory(self):
6363 self .assertTrue (clone_1 .common_dir , clone_2 .common_dir )
6464 self .assertTrue (clone_1 .working_dir , clone_2 .working_dir )
6565
66+ def test_clone_to_directory_newer_commit (self ):
67+ """
68+ Check that the repository is pulled when a newer commit is configured.
69+ """
70+ description_name = "simple_humanoid_description"
71+ repo_params = REPOSITORIES [description_name ]
72+
73+ def get_commit (repo ):
74+ # return str(list(repo.iter_commits(max_count=1))[0])
75+ return repo .git .rev_parse ("HEAD" )
76+
77+ with tempfile .TemporaryDirectory () as tmp_dir :
78+ repo_dir = os .path .join (tmp_dir , "test" )
79+ repo = clone_to_directory (
80+ repo_params .url , repo_dir , commit = repo_params .commit
81+ )
82+ self .assertFalse (repo .bare )
83+ self .assertEqual (get_commit (repo ), repo_params .commit )
84+ repo .git .reset ("HEAD~1" , "--hard" )
85+ self .assertNotEqual (get_commit (repo ), repo_params .commit )
86+ repo_bis = clone_to_directory (
87+ repo_params .url , repo_dir , commit = repo_params .commit
88+ )
89+ self .assertEqual (get_commit (repo ), repo_params .commit )
90+ self .assertEqual (get_commit (repo_bis ), repo_params .commit )
91+
6692 def test_clone_to_cache_found (self ):
6793 """
6894 Test clone_to_cache on a valid repository.
0 commit comments