예제 #1
0
파일: test_git.py 프로젝트: wjt2015/conan
 def test_clone_git_shallow_revision(self):
     path, revision = create_local_git_repo({"myfile": "contents"},
                                            commits=3,
                                            tags=["1.0"],
                                            branch="develop")
     tmp = temp_folder()
     git = Git(tmp)
     if Git.get_version() < "2.13":
         # older Git versions have known bugs with "git fetch origin <sha>":
         # https://github.com/git/git/blob/master/Documentation/RelNotes/2.13.0.txt
         #  * "git fetch" that requests a commit by object name, when the other
         #    side does not allow such an request, failed without much
         #    explanation.
         # https://github.com/git/git/blob/master/Documentation/RelNotes/2.14.0.txt
         # * There is no good reason why "git fetch $there $sha1" should fail
         #    when the $sha1 names an object at the tip of an advertised ref,
         #    even when the other side hasn't enabled allowTipSHA1InWant.
         with self.assertRaises(subprocess.CalledProcessError):
             git.clone("file://" + path, branch=revision, shallow=True)
     else:
         git.clone("file://" + path, branch=revision, shallow=True)
         with self.assertRaises(subprocess.CalledProcessError):
             git.checkout(element="HEAD~1")
         self.assertTrue(os.path.exists(os.path.join(tmp, "myfile")))
         self.assertEqual(git.get_revision(), revision)
         self.assertEqual(git.run("rev-list --all --count"), "1")
예제 #2
0
파일: test_git.py 프로젝트: manuelbcd/conan
 def test_clone_git_shallow(self, element):
     path, revision = create_local_git_repo({"myfile": "contents"}, commits=3, tags=["1.0"], branch="develop")
     tmp = temp_folder()
     git = Git(tmp)
     git.clone("file://" + path, branch=element, shallow=True)  # --depth is ignored in local clones
     with self.assertRaises(subprocess.CalledProcessError):
         git.checkout(element="HEAD~1")
     self.assertTrue(os.path.exists(os.path.join(tmp, "myfile")))
     self.assertEqual(git.get_revision(), revision)
     self.assertEqual(git.run("rev-list --all --count"), "1")
예제 #3
0
파일: test_git.py 프로젝트: manuelbcd/conan
    def test_clone_existing_folder_git(self):
        path, commit = create_local_git_repo({"myfile": "contents"}, branch="my_release")

        tmp = temp_folder()
        save(os.path.join(tmp, "file"), "dummy contents")
        git = Git(tmp)
        git.clone(path, branch="my_release")
        self.assertTrue(os.path.exists(os.path.join(tmp, "myfile")))

        # Checkout a commit
        git.checkout(commit)
        self.assertEqual(git.get_revision(), commit)
예제 #4
0
    def test_clone_submodule_git(self):
        subsubmodule, _ = create_local_git_repo({"subsubmodule": "contents"})
        submodule, _ = create_local_git_repo({"submodule": "contents"},
                                             submodules=[subsubmodule])
        path, commit = create_local_git_repo({"myfile": "contents"},
                                             submodules=[submodule])

        def _create_paths():
            tmp = temp_folder()
            submodule_path = os.path.join(
                tmp, os.path.basename(os.path.normpath(submodule)))
            subsubmodule_path = os.path.join(
                submodule_path,
                os.path.basename(os.path.normpath(subsubmodule)))
            return tmp, submodule_path, subsubmodule_path

        # Check old (default) behaviour
        tmp, submodule_path, _ = _create_paths()
        git = Git(tmp)
        git.clone(path)
        self.assertTrue(os.path.exists(os.path.join(tmp, "myfile")))
        self.assertFalse(
            os.path.exists(os.path.join(submodule_path, "submodule")))

        # Check invalid value
        tmp, submodule_path, _ = _create_paths()
        git = Git(tmp)
        git.clone(path)
        with six.assertRaisesRegex(
                self, ConanException,
                "Invalid 'submodule' attribute value in the 'scm'."):
            git.checkout(commit, submodule="invalid")

        # Check shallow
        tmp, submodule_path, subsubmodule_path = _create_paths()
        git = Git(tmp)
        git.clone(path)
        git.checkout(commit, submodule="shallow")
        self.assertTrue(os.path.exists(os.path.join(tmp, "myfile")))
        self.assertTrue(
            os.path.exists(os.path.join(submodule_path, "submodule")))
        self.assertFalse(
            os.path.exists(os.path.join(subsubmodule_path, "subsubmodule")))

        # Check recursive
        tmp, submodule_path, subsubmodule_path = _create_paths()
        git = Git(tmp)
        git.clone(path)
        git.checkout(commit, submodule="recursive")
        self.assertTrue(os.path.exists(os.path.join(tmp, "myfile")))
        self.assertTrue(
            os.path.exists(os.path.join(submodule_path, "submodule")))
        self.assertTrue(
            os.path.exists(os.path.join(subsubmodule_path, "subsubmodule")))