Exemple #1
0
 def testRebase(self):
     try:
         os.chdir(self.repo)
         f1name = os.path.join(self.repo, "f1")
         writeFile1(f1name)
         git.add(f1name)
         git.commit("-m \"initial commit\"")
         git.branch("testRebase/branchToRebase HEAD")
         # while still on master add another commit.
         writeFile2(f1name)
         git.add(f1name)
         git.commit("-m \"edited f1\"")
         # switch to new branch, add a new file, commit, rebase onto master.
         git.checkout("testRebase/branchToRebase")
         f2name = os.path.join(self.repo, "f2")
         writeFile2(f2name)
         git.add(f2name)
         git.commit("-m \"added f2\" ")
         self.assertFalse(
             git.branchUpToDateWith("testRebase/branchToRebase", "master"),
             "attempting rebase in situation where rebase will not do anything."
         )
         try:
             git.rebase("master")
             self.assertTrue(
                 git.branchUpToDateWith("testRebase/branchToRebase",
                                        "master"),
                 "rebase did not bring current branch up to date with master"
             )
         except git.GrapeGitError as error:
             self.assertTrue(
                 False,
                 "rebase that should not have generated a conflict failed")
     except git.GrapeGitError as error:
         self.handleGitError(error)
Exemple #2
0
 def testRebase(self):
     try:
         os.chdir(self.repo)
         f1name = os.path.join(self.repo,"f1")
         writeFile1(f1name)
         git.add(f1name)
         git.commit("-m \"initial commit\"")
         git.branch("testRebase/branchToRebase HEAD")
         # while still on master add another commit.
         writeFile2(f1name)
         git.add(f1name)
         git.commit("-m \"edited f1\"")
         # switch to new branch, add a new file, commit, rebase onto master.
         git.checkout("testRebase/branchToRebase")
         f2name = os.path.join(self.repo,"f2")
         writeFile2(f2name)
         git.add(f2name)
         git.commit("-m \"added f2\" ")
         self.assertFalse(git.branchUpToDateWith("testRebase/branchToRebase","master"),"attempting rebase in situation where rebase will not do anything.")
         try:
             git.rebase("master")
             self.assertTrue(git.branchUpToDateWith("testRebase/branchToRebase","master"),"rebase did not bring current branch up to date with master")
         except git.GrapeGitError as error:
             self.assertTrue(False,"rebase that should not have generated a conflict failed")
     except git.GrapeGitError as error:
         self.handleGitError(error)
Exemple #3
0
 def assertSuccessfulSquashCascadeMerge(self, fromBranch="testPublish", toBranch="master", cascadeDest="develop"):
     currentBranch = git.currentBranch()
     self.assertTrue(currentBranch == cascadeDest)
     self.assertFalse(git.diff("--name-only %s %s" % (toBranch, fromBranch)))
     self.assertFalse(git.diff("--name-only %s %s" % (toBranch, cascadeDest)))
     self.assertTrue(git.branchUpToDateWith(toBranch, cascadeDest))
     self.assertFalse(git.branchUpToDateWith(toBranch, fromBranch))
Exemple #4
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())
Exemple #5
0
 def assertSuccessfulSquashCascadeMerge(self,
                                        fromBranch="testPublish",
                                        toBranch="master",
                                        cascadeDest="develop"):
     currentBranch = git.currentBranch()
     self.assertTrue(currentBranch == cascadeDest)
     self.assertFalse(git.diff("--name-only %s %s" %
                               (toBranch, fromBranch)))
     self.assertFalse(
         git.diff("--name-only %s %s" % (toBranch, cascadeDest)))
     self.assertTrue(git.branchUpToDateWith(toBranch, cascadeDest))
     self.assertFalse(git.branchUpToDateWith(toBranch, fromBranch))
Exemple #6
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())
Exemple #7
0
    def testConflictingNestedSubprojectMerge_MD(self):
        self.setUpConflictingNestedSubprojectMerge()
        os.chdir(self.repo)
        git.checkout(" -b testNestedMerge")

        #make sure we're not up to date with master
        os.chdir(self.subproject)
        self.assertFalse(git.branchUpToDateWith("testNestedMerge", "master"),
                         msg=None)
        os.chdir(self.repo)
        # run grape md --am
        try:
            ret = grapeMenu.menu().applyMenuChoice("md",
                                                   ["--am", "--public=master"],
                                                   globalArgs=["-v"])
        except SystemExit as e:
            self.assertTrue(False, "grape md raised exception %s" % e)
        self.assertFalse(
            ret, "grape md did not return False for conflicting merge.")
        # git status in outer repo should be clean
        status = git.status("--porcelain")
        self.assertFalse(
            status,
            "status is not empty in outer repo after conflict in subproject")
        # git status in subproject should not be clean
        os.chdir(self.subproject)
        status = git.status("--porcelain")
        self.assertIn("AA", status, "no conflicts in subproject status")

        # resolve the conflict
        git.checkout("--ours f1")
        git.add("f1")
        status = git.status("--porcelain")
        self.assertNotIn("AA", status,
                         "conflict not resolved after staging f1")

        # continue the merge
        ret = grapeMenu.menu().applyMenuChoice("md", ["--continue"])
        self.assertTrue(
            ret, "md didn't return successfully after conflict resolution")
        os.chdir(self.subproject)

        self.assertTrue(git.branchUpToDateWith("testNestedMerge", "master"))
        os.chdir(self.repo)
        self.assertTrue(git.branchUpToDateWith("testNestedMerge", "master"))
Exemple #8
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())
Exemple #9
0
    def testConflictingNestedSubprojectMerge_MD(self):
        self.setUpConflictingNestedSubprojectMerge()
        os.chdir(self.repo)
        git.checkout(" -b testNestedMerge")
        
        #make sure we're not up to date with master
        os.chdir(self.subproject)
        self.assertFalse(git.branchUpToDateWith("testNestedMerge", "master"), msg=None)
        os.chdir(self.repo)
        # run grape md --am
        try:
            ret = grapeMenu.menu().applyMenuChoice("md", ["--am", "--public=master"], globalArgs=["-v"])
        except SystemExit as e: 
            self.assertTrue(False, "grape md raised exception %s" % e)
        self.assertFalse(ret, "grape md did not return False for conflicting merge.")
        # git status in outer repo should be clean
        status = git.status("--porcelain")
        self.assertFalse(status, "status is not empty in outer repo after conflict in subproject")
        # git status in subproject should not be clean
        os.chdir(self.subproject)
        status = git.status("--porcelain")
        self.assertIn("AA", status, "no conflicts in subproject status")
        
        # resolve the conflict
        git.checkout("--ours f1")
        git.add("f1")
        status = git.status("--porcelain")
        self.assertNotIn("AA", status, "conflict not resolved after staging f1")
        
        # continue the merge
        ret = grapeMenu.menu().applyMenuChoice("md", ["--continue"])
        self.assertTrue(ret, "md didn't return successfully after conflict resolution")
        os.chdir(self.subproject)

        self.assertTrue(git.branchUpToDateWith("testNestedMerge", "master"))
        os.chdir(self.repo)
        self.assertTrue(git.branchUpToDateWith("testNestedMerge", "master"))
Exemple #10
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())