Пример #1
0
    def testNonConflictingSubmoduleMerge(self):
        try:
            self.setUpNonConflictingSubmoduleMerge()
            ret = grapeMenu.menu().applyMenuChoice("m", ["master", "--am"])
            self.assertTrue(
                ret, "grape m did not return true for submodule merge.")

            # the submodule should not be modified
            self.assertTrue(git.isWorkingDirectoryClean())

            # master should be merged into current branch
            self.assertTrue(
                git.branchUpToDateWith("testSubmoduleMerge", "master"))

            # the gitlink should be at the tip of testSubmoduleMerge
            git.submodule("update")
            os.chdir(os.path.join(self.repo, "submodule1"))
            self.assertFalse(
                git.diff("testSubmoduleMerge"),
                "gitlink is not at testSubmoduleMerge tip after merge")

        except git.GrapeGitError as e:
            self.fail("Uncaught git error executing %s: \n%s" %
                      (e.gitCommand, e.gitOutput))
        except SystemExit:
            self.fail("Uncaught System Exit\n%s" % self.output.getvalue())
Пример #2
0
    def setUpNonConflictingSubmoduleMerge(self):
        os.chdir(self.defaultWorkingDirectory)
        self.createTestSubmodule()
        git.branch("testSubmoduleMerge")
        # create a new commit in submodule1
        os.chdir(os.path.join(self.repo, "submodule1"))
        git.checkout("master")
        testGrape.writeFile2("f1")
        git.add("f1")
        git.commit("-m \"added f2 as f1\"")
        # update outer level with new commit
        os.chdir(self.repo)
        git.commit(
            "submodule1 -m \"updated submodule gitlink on master branch\"")

        # setup what should be a notionally-conflict free merge
        # (grape needs to deal with the gitlink conflicts automatically)
        git.checkout("testSubmoduleMerge")
        git.submodule("update")
        os.chdir(os.path.join(self.repo, "submodule1"))
        git.checkout("-b testSubmoduleMerge")
        testGrape.writeFile3("f2")
        git.add("f2")
        git.commit("-m \"added f3 as f2\"")
        os.chdir(self.repo)
        git.commit("-a -m \"updated gitlink on branch testSubmoduleMerge\"")
        self.setUpConfig()
Пример #3
0
 def setUpConflictingSubmoduleMerge(self):
     os.chdir(self.defaultWorkingDirectory)
     self.createTestSubmodule()
     git.branch("testSubmoduleMerge2")
     subPath = os.path.join(self.repo, "submodule1")
     os.chdir(subPath)
     git.branch("testSubmoduleMerge2")
     git.checkout("master")
     testGrape.writeFile2("f1")
     git.add("f1")
     git.commit("-m \"added f2 as f1\"")
     os.chdir(self.repo)
     git.commit(
         "submodule1 -m \"updated submodule gitlink on master branch\"")
     git.checkout("testSubmoduleMerge2")
     git.submodule("update")
     os.chdir(subPath)
     git.checkout("testSubmoduleMerge2")
     testGrape.writeFile3("f1")
     git.add("f1")
     git.commit("-m \"added f3 as f1\"")
     os.chdir(self.repo)
     git.commit(
         "submodule1 -m \"updated submodule gitlink on testSubmoduleMerge branch\""
     )
     self.setUpConfig()
Пример #4
0
    def setUpSubmoduleBranch(self):
        git.clone("%s %s" % (self.repo, self.repos[1]))
        os.chdir(self.repo)
        git.checkout("-b addSubmodule")
        git.submodule("add %s submodule" % self.repos[1])
        git.commit("-m \"added submodule\"")
        git.push("origin HEAD")

        # put the remote for the submodule into a HEAD-less state so it can accept pushes
        os.chdir(self.repos[1])
        git.checkout("--orphan HEAD")

        # go to the submodule and add a file to it.
        os.chdir(os.path.join(self.repo,"submodule"))
        f2 = os.path.join(self.repo,"submodule","f2")
        testGrape.writeFile2(f2)
        git.checkout("-b addSubmodule")
        git.add(f2)
        git.commit("-m \"added f2\"")

        # add another file on the master branch for the submodule
        git.branch("-f master HEAD")
        git.checkout("master")
        f3 = os.path.join(self.repo, "submodule", "f3")
        testGrape.writeFile3(f3)
        git.add(f3)
        git.commit("f3 -m \"f3\"")

        # update the submodule's remote
        git.push("origin --all")

        # git back to the master branch in the original repository
        os.chdir(self.repo)
        git.checkout("master")
Пример #5
0
    def setUpSubmoduleBranch(self):
        git.clone("%s %s" % (self.repo, self.repos[1]))
        os.chdir(self.repo)
        git.checkout("-b addSubmodule")
        git.submodule("add %s submodule" % self.repos[1])
        git.commit("-m \"added submodule\"")
        git.push("origin HEAD")

        # put the remote for the submodule into a HEAD-less state so it can accept pushes
        os.chdir(self.repos[1])
        git.checkout("--orphan HEAD")

        # go to the submodule and add a file to it.
        os.chdir(os.path.join(self.repo, "submodule"))
        f2 = os.path.join(self.repo, "submodule", "f2")
        testGrape.writeFile2(f2)
        git.checkout("-b addSubmodule")
        git.add(f2)
        git.commit("-m \"added f2\"")

        # add another file on the master branch for the submodule
        git.branch("-f master HEAD")
        git.checkout("master")
        f3 = os.path.join(self.repo, "submodule", "f3")
        testGrape.writeFile3(f3)
        git.add(f3)
        git.commit("f3 -m \"f3\"")

        # update the submodule's remote
        git.push("origin --all")

        # git back to the master branch in the original repository
        os.chdir(self.repo)
        git.checkout("master")
Пример #6
0
    def setUpNonConflictingSubmoduleMerge(self):
        os.chdir(self.defaultWorkingDirectory)
        self.createTestSubmodule()
        git.branch("testSubmoduleMerge")
        # create a new commit in submodule1
        os.chdir(os.path.join(self.repo, "submodule1"))
        git.checkout("master")
        testGrape.writeFile2("f1")
        git.add("f1")
        git.commit("-m \"added f2 as f1\"")
        # update outer level with new commit
        os.chdir(self.repo)
        git.commit("submodule1 -m \"updated submodule gitlink on master branch\"")

        # setup what should be a notionally-conflict free merge
        # (grape needs to deal with the gitlink conflicts automatically)
        git.checkout("testSubmoduleMerge")
        git.submodule("update")
        os.chdir(os.path.join(self.repo, "submodule1"))
        git.checkout("-b testSubmoduleMerge")
        testGrape.writeFile3("f2")
        git.add("f2")
        git.commit("-m \"added f3 as f2\"")
        os.chdir(self.repo)
        git.commit("-a -m \"updated gitlink on branch testSubmoduleMerge\"")
        self.setUpConfig()
Пример #7
0
 def createTestSubmodule(self):
     # make a repo to turn into a submodule
     git.clone("--mirror %s %s " % (self.repo, self.repos[1]))
     # add repo2 as a submodule to repo1
     os.chdir(self.repo)
     git.submodule("add %s %s" % (os.path.join(self.repos[1]), "submodule1"))
     git.commit("-m \"added submodule1\"")
Пример #8
0
 def createTestSubmodule(self):
     # make a repo to turn into a submodule
     git.clone("--mirror %s %s " % (self.repo, self.repos[1]))
     # add repo2 as a submodule to repo1
     os.chdir(self.repo)
     git.submodule("add %s %s" %
                   (os.path.join(self.repos[1]), "submodule1"))
     git.commit("-m \"added submodule1\"")
Пример #9
0
    def testConflictingSubmoduleMerge(self):
        try:
            self.setUpConflictingSubmoduleMerge()
            subPath = os.path.join(self.repo, "submodule1")
            ret = grapeMenu.menu().applyMenuChoice("m", ["master", "--am"])
            self.assertFalse(
                ret, "grape m did not return False for conflicting merge.")
            # should only have modifications in submodule1, not conflicts
            status = git.status("--porcelain")
            self.assertTrue("UU" not in status and "AA" in status,
                            "unexpected status %s at toplevel" % status)
            os.chdir(subPath)
            status = git.status("--porcelain")
            self.assertTrue("AA" in status,
                            "unexpected status %s in submodule1" % status)

            # resolve the conflict and continue from the submodule's directory
            git.checkout("--ours f1")
            git.add("f1")
            git.commit("-m \"resolved conflict with our f1\"")
            self.setUpConfig()
            ret = grapeMenu.menu().applyMenuChoice("m", ["--continue"])

            # test that we returned successfully
            self.assertTrue(
                ret,
                "grape m --continue did not complete successfully after resolving submodule conflict"
                "\n %s" % self.output.getvalue())

            # test that the submodule master was merged in
            self.assertTrue(
                git.branchUpToDateWith("testSubmoduleMerge2", "master"),
                "grape m --continue did not merge in submodule1`s master branch"
            )

            # test that the outer level master was merged in
            os.chdir(self.repo)
            self.assertTrue(
                git.branchUpToDateWith("testSubmoduleMerge2", "master"),
                "grape m --continue did not merge in the outer level master branch"
            )

            # ensure the gitlink is at the right commit
            git.submodule("update")
            os.chdir(subPath)
            diff = git.diff("testSubmoduleMerge2")
            self.assertFalse(
                diff,
                "checked in gitlink is not at tip of testSubmoduleMerge2")

        except git.GrapeGitError as e:
            self.fail("Uncaught git error executing %s: \n%s" %
                      (e.gitCommand, e.gitOutput))
        except SystemExit:
            self.fail("Uncaught exit\n%s" % self.output.getvalue())
Пример #10
0
    def testConflictingSubmoduleMerge(self):
        try:
            self.setUpConflictingSubmoduleMerge()
            subPath = os.path.join(self.repo, "submodule1")
            ret = grapeMenu.menu().applyMenuChoice("m", ["master", "--am"])
            self.assertFalse(ret, "grape m did not return False for conflicting merge.")
            # should only have modifications in submodule1, not conflicts
            status = git.status("--porcelain")
            self.assertTrue("UU" not in status and "AA" in status, "unexpected status %s at toplevel" % status)
            os.chdir(subPath)
            status = git.status("--porcelain")
            self.assertTrue("AA" in status, "unexpected status %s in submodule1" % status)

            # resolve the conflict and continue from the submodule's directory
            git.checkout("--ours f1")
            git.add("f1")
            git.commit("-m \"resolved conflict with our f1\"")
            self.setUpConfig()
            ret = grapeMenu.menu().applyMenuChoice("m", ["--continue"])

            # test that we returned successfully
            self.assertTrue(ret, "grape m --continue did not complete successfully after resolving submodule conflict"
                                 "\n %s" % self.output.getvalue())

            # test that the submodule master was merged in
            self.assertTrue(git.branchUpToDateWith("testSubmoduleMerge2", "master"),
                            "grape m --continue did not merge in submodule1`s master branch")

            # test that the outer level master was merged in
            os.chdir(self.repo)
            self.assertTrue(git.branchUpToDateWith("testSubmoduleMerge2", "master"),
                            "grape m --continue did not merge in the outer level master branch")

            # ensure the gitlink is at the right commit
            git.submodule("update")
            os.chdir(subPath)
            diff = git.diff("testSubmoduleMerge2")
            self.assertFalse(diff, "checked in gitlink is not at tip of testSubmoduleMerge2")

        except git.GrapeGitError as e:
            self.fail("Uncaught git error executing %s: \n%s" % (e.gitCommand, e.gitOutput))
        except SystemExit:
            self.fail("Uncaught exit\n%s" % self.output.getvalue())
Пример #11
0
    def testRecursiveCloneWithSubmodule(self):
        # make a repo to turn into a submodule
        git.clone("--mirror %s %s " % (self.repo, self.repos[1]))
        # add repo2 as a submodule to repo1
        os.chdir(self.repo)
        git.submodule("add %s %s" % (os.path.join(self.repos[1]), "submodule1"))
        git.commit("-m \"added submodule1\"")

        #Now clone the repo into a temp dir and make sure the submodule is in the clone
        try:
            tempDir = tempfile.mkdtemp()
            args = [self.repo, tempDir, "--recursive"]
            self.queueUserInput(["\n", "\n", "\n", "\n","\n","\n"])
            ret = grapeMenu.menu().applyMenuChoice("clone", args)
            self.assertTrue(ret, "vine.clone returned failure")

            submodulepath = os.path.join(tempDir, "submodule1")
            self.assertTrue(os.path.exists(submodulepath), "submodule1 does not exist in clone")
        finally:
            shutil.rmtree(tempDir)
Пример #12
0
    def testNonConflictingSubmoduleMerge(self):
        try:
            self.setUpNonConflictingSubmoduleMerge()
            ret = grapeMenu.menu().applyMenuChoice("m", ["master", "--am"])
            self.assertTrue(ret, "grape m did not return true for submodule merge.")

            # the submodule should not be modified
            self.assertTrue(git.isWorkingDirectoryClean())

            # master should be merged into current branch
            self.assertTrue(git.branchUpToDateWith("testSubmoduleMerge", "master"))

            # the gitlink should be at the tip of testSubmoduleMerge
            git.submodule("update")
            os.chdir(os.path.join(self.repo, "submodule1"))
            self.assertFalse(git.diff("testSubmoduleMerge"), "gitlink is not at testSubmoduleMerge tip after merge")

        except git.GrapeGitError as e:
            self.fail("Uncaught git error executing %s: \n%s" % (e.gitCommand, e.gitOutput))
        except SystemExit:
            self.fail("Uncaught System Exit\n%s" % self.output.getvalue())
Пример #13
0
 def setUpConflictingSubmoduleMerge(self):
     os.chdir(self.defaultWorkingDirectory)
     self.createTestSubmodule()
     git.branch("testSubmoduleMerge2")
     subPath = os.path.join(self.repo, "submodule1")
     os.chdir(subPath)
     git.branch("testSubmoduleMerge2")
     git.checkout("master")
     testGrape.writeFile2("f1")
     git.add("f1")
     git.commit("-m \"added f2 as f1\"")
     os.chdir(self.repo)
     git.commit("submodule1 -m \"updated submodule gitlink on master branch\"")
     git.checkout("testSubmoduleMerge2")
     git.submodule("update")
     os.chdir(subPath)
     git.checkout("testSubmoduleMerge2")
     testGrape.writeFile3("f1")
     git.add("f1")
     git.commit("-m \"added f3 as f1\"")
     os.chdir(self.repo)
     git.commit("submodule1 -m \"updated submodule gitlink on testSubmoduleMerge branch\"")
     self.setUpConfig()