Beispiel #1
0
 def assertCanAddNewSubproject(testGrapeObject):
     git.clone("--mirror %s %s" % (testGrapeObject.repo, testGrapeObject.repos[1]))
     os.chdir(testGrapeObject.repo)
     grapeMenu.menu().applyMenuChoice("addSubproject", ["--name=subproject1", "--prefix=subs/subproject1",
                                                        "--branch=master", "--url=%s" % testGrapeObject.repos[1],
                                                        "--nested", "--noverify"])
     subproject1path = os.path.join(testGrapeObject.repo, "subs/subproject1")
     testGrapeObject.assertTrue(os.path.exists(subproject1path), "subproject1 does not exist")
     os.chdir(subproject1path)
     # check to see that subproject1 is a git repo
     basedir = os.path.split(git.baseDir())[-1]
     subdir = os.path.split(subproject1path)[-1]
     testGrapeObject.assertTrue(basedir == subdir, "subproject1's git repo is %s, not %s" % (basedir, subdir))
     # check to see that edits that occur in the new subproject are ignored by outer repo
     testGrape.writeFile3(os.path.join(subproject1path, "f3"))
     # make sure there is an edit
     testGrapeObject.assertFalse(git.isWorkingDirectoryClean(), "subproject1 clean after adding f3")
     os.chdir(testGrapeObject.repo)
     # check that grape left the repository in a clean state
     testGrapeObject.assertTrue(git.isWorkingDirectoryClean(), "repo not clean after added subproject1")
     # check in the edit
     os.chdir(subproject1path)
     git.add("f3")
     git.commit("-m \"added f3\"")
     testGrapeObject.assertTrue(git.isWorkingDirectoryClean(), "subproject1 not clean")
     os.chdir(testGrapeObject.repo)
     testGrapeObject.subproject = subproject1path
Beispiel #2
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")
Beispiel #3
0
    def testRecursiveCloneNestedSubproject(self):
        # make a repo to turn into a submodule
        git.clone("--mirror %s %s " % (self.repo, self.repos[1]))
        os.chdir(self.repo)
        grapeMenu.menu().applyMenuChoice("addSubproject", ["--name=subproject1", "--prefix=subs/subproject1",
                                                           "--branch=master", "--url=%s" % self.repos[1],
                                                           "--nested", "--noverify"])
        grapeMenu.menu().applyMenuChoice("commit",["-m", "\"added subproject1\""])
        print git.log("--decorate")

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

            # ensure we are on master with all nested subprojects
            os.chdir(tempDir)
            self.queueUserInput(["all\n"])
            args = ["master", "--updateView"]
            ret = grapeMenu.menu().applyMenuChoice("checkout", args)
            self.assertTrue(ret, "vine.checkout master returned failure")
            print git.log("--decorate")

            subprojectpath = os.path.join(tempDir, "subs/subproject1")
            self.assertTrue(os.path.exists(subprojectpath), "subproject1 does not exist in clone")
        finally:
            shutil.rmtree(tempDir)
Beispiel #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")
Beispiel #5
0
    def testPush(self):
        try:
            os.chdir(self.repo)
            f2name = os.path.join(self.repo, "f2")
            writeFile2(f2name)
            git.add(f2name)
            git.commit(" -m \"initial commit for testPush\"")
            git.clone("%s %s" % (self.repo, self.repos[1]))
            git.checkout("-b testPush/tmpBranchToAllowPushesToMaster")
            os.chdir(self.repos[1])
            f1name = os.path.join(self.repos[1], "f1")
            writeFile1(f1name)
            git.add("f1")
            commitStr = "testPush: added f1"
            git.commit(" -m \"%s\"" % commitStr)
            os.chdir(self.repo)
            log = git.log("--all")
            self.assertFalse(commitStr in log,
                             "commit message in log before it should be")
            os.chdir(self.repos[1])
            pushOutput = git.push("origin master")
            os.chdir(self.repo)
            git.checkout("master")
            log = git.log()
            self.assertTrue(commitStr in log,
                            "commit message not in log after push")

        except git.GrapeGitError as error:
            self.handleGitError(error)
Beispiel #6
0
    def testPush(self):
        try:
            os.chdir(self.repo)
            f2name = os.path.join(self.repo, "f2")
            writeFile2(f2name)
            git.add(f2name)
            git.commit(" -m \"initial commit for testPush\"")
            git.clone("%s %s" %(self.repo,self.repos[1]))
            git.checkout("-b testPush/tmpBranchToAllowPushesToMaster")
            os.chdir(self.repos[1])
            f1name = os.path.join(self.repos[1],"f1")
            writeFile1(f1name)
            git.add("f1")
            commitStr = "testPush: added f1"
            git.commit(" -m \"%s\"" % commitStr)
            os.chdir(self.repo)
            log = git.log("--all")
            self.assertFalse(commitStr in log,"commit message in log before it should be")
            os.chdir(self.repos[1])
            pushOutput = git.push("origin master")
            os.chdir(self.repo)
            git.checkout("master")
            log = git.log()
            self.assertTrue(commitStr in log, "commit message not in log after push")

        except git.GrapeGitError as error:
            self.handleGitError(error)
Beispiel #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\"")
Beispiel #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\"")
Beispiel #9
0
    def testPull(self):
        try:
            git.clone("%s %s" %(self.repo,self.repos[1]))
            os.chdir(self.repo)
            f1name = os.path.join(self.repo,"f1")
            writeFile1(f1name)
            git.add("f1")
            commitStr = "testPull: added f1"
            git.commit(" -m \"%s\"" % commitStr)
            os.chdir(self.repos[1])
            log = git.log("--all")
            self.assertFalse(commitStr in log,"commit message in log before it should be")
            git.pull("origin master")
            log = git.log()
            self.assertTrue(commitStr in log, "commit message not in log after pull")

        except git.GrapeGitError as error:
            self.handleGitError(error)
Beispiel #10
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)
Beispiel #11
0
    def testPull(self):
        try:
            git.clone("%s %s" % (self.repo, self.repos[1]))
            os.chdir(self.repo)
            f1name = os.path.join(self.repo, "f1")
            writeFile1(f1name)
            git.add("f1")
            commitStr = "testPull: added f1"
            git.commit(" -m \"%s\"" % commitStr)
            os.chdir(self.repos[1])
            log = git.log("--all")
            self.assertFalse(commitStr in log,
                             "commit message in log before it should be")
            git.pull("origin master")
            log = git.log()
            self.assertTrue(commitStr in log,
                            "commit message not in log after pull")

        except git.GrapeGitError as error:
            self.handleGitError(error)
Beispiel #12
0
 def testCloneAndShowRemote(self):
     localSource = self.repo
     localClone = self.repos[1]
     try:
         self.assertTrue(git.clone("%s %s" % (localSource,localClone) ))
         os.chdir(localClone)
         fetchLine = "Fetch URL: %s" % localSource
         showRemoteOutput = git.showRemote()
         self.assertTrue(fetchLine in showRemoteOutput,"coud not find %s in output" % fetchLine)
     except git.GrapeGitError as error:
         self.handleGitError(error)
Beispiel #13
0
 def testCloneAndShowRemote(self):
     localSource = self.repo
     localClone = self.repos[1]
     try:
         self.assertTrue(git.clone("%s %s" % (localSource, localClone)))
         os.chdir(localClone)
         fetchLine = "Fetch URL: %s" % localSource
         showRemoteOutput = git.showRemote()
         self.assertTrue(fetchLine in showRemoteOutput,
                         "coud not find %s in output" % fetchLine)
     except git.GrapeGitError as error:
         self.handleGitError(error)
Beispiel #14
0
 def assertCanAddNewSubproject(testGrapeObject):
     git.clone("--mirror %s %s" %
               (testGrapeObject.repo, testGrapeObject.repos[1]))
     os.chdir(testGrapeObject.repo)
     grapeMenu.menu().applyMenuChoice("addSubproject", [
         "--name=subproject1", "--prefix=subs/subproject1",
         "--branch=master",
         "--url=%s" % testGrapeObject.repos[1], "--nested", "--noverify"
     ])
     subproject1path = os.path.join(testGrapeObject.repo,
                                    "subs/subproject1")
     testGrapeObject.assertTrue(os.path.exists(subproject1path),
                                "subproject1 does not exist")
     os.chdir(subproject1path)
     # check to see that subproject1 is a git repo
     basedir = os.path.split(git.baseDir())[-1]
     subdir = os.path.split(subproject1path)[-1]
     testGrapeObject.assertTrue(
         basedir == subdir,
         "subproject1's git repo is %s, not %s" % (basedir, subdir))
     # check to see that edits that occur in the new subproject are ignored by outer repo
     testGrape.writeFile3(os.path.join(subproject1path, "f3"))
     # make sure there is an edit
     testGrapeObject.assertFalse(git.isWorkingDirectoryClean(),
                                 "subproject1 clean after adding f3")
     os.chdir(testGrapeObject.repo)
     # check that grape left the repository in a clean state
     testGrapeObject.assertTrue(git.isWorkingDirectoryClean(),
                                "repo not clean after added subproject1")
     # check in the edit
     os.chdir(subproject1path)
     git.add("f3")
     git.commit("-m \"added f3\"")
     testGrapeObject.assertTrue(git.isWorkingDirectoryClean(),
                                "subproject1 not clean")
     os.chdir(testGrapeObject.repo)
     testGrapeObject.subproject = subproject1path