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)
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)
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)
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)
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)
def testCommit(self): try: os.chdir(self.repo) f1name = os.path.join(self.repo, "f1") writeFile1(f1name) commitStr = "testCommit: added f1" git.add("f1") git.commit("f1 -m \"%s\"" % commitStr) log = git.log() self.assertTrue(commitStr in log) except git.GrapeGitError as error: self.handleGitError(error)
def testCommit(self): try: os.chdir(self.repo) f1name = os.path.join(self.repo,"f1") writeFile1(f1name) commitStr = "testCommit: added f1" git.add("f1") git.commit("f1 -m \"%s\"" % commitStr) log = git.log() self.assertTrue(commitStr in log) except git.GrapeGitError as error: self.handleGitError(error)
def testMerge(self): # First, test to see if a merge that should work does. try: os.chdir(self.repo) #add a file on the master branch. f1name = os.path.join(self.repo, "f1") writeFile1(f1name) git.add("f1") commitStr = "testMerge: added f1" git.commit(" -m \"%s\"" % commitStr) # edit it on branch testMerge/tmp1 git.checkout("-b testMerge/tmp1") writeFile2(f1name) git.commit("-a -m \"edited f1\"") # perform same editon master git.checkout("master") writeFile2(f1name) git.commit("-a -m \"edited f1 on master\"") # switch back to tmp, merge changes from master down git.checkout("testMerge/tmp1") output = git.merge( "master -m \"merged identical change from master\"") log = git.log() self.assertTrue("identical change from master" in log) except git.GrapeGitError as error: self.handleGitError(error) # Second, test that a merge that should result in a conflict throws an appropriate GrapeGitError exception. try: git.checkout("master") f2name = os.path.join(self.repo, "f2") writeFile3(f2name) git.add(f2name) git.commit("-m \"added f2\"") git.checkout("testMerge/tmp1") writeFile2(f2name) git.add(f2name) git.commit("-m \"added f2 in tmp branch\"") git.merge("master -m \"merged master branch into testmerge/tmp1\"") self.assertTrue(False, "Merge did not throw grapeGitError for conflict") except git.GrapeGitError as error: status = git.status() self.assertTrue("conflict" in status, "'conflict' not in status message %s" % status)
def testMerge(self): # First, test to see if a merge that should work does. try: os.chdir(self.repo) #add a file on the master branch. f1name = os.path.join(self.repo, "f1") writeFile1(f1name) git.add("f1") commitStr = "testMerge: added f1" git.commit(" -m \"%s\"" % commitStr) # edit it on branch testMerge/tmp1 git.checkout("-b testMerge/tmp1") writeFile2(f1name) git.commit("-a -m \"edited f1\"") # perform same editon master git.checkout("master") writeFile2(f1name) git.commit("-a -m \"edited f1 on master\"") # switch back to tmp, merge changes from master down git.checkout("testMerge/tmp1") output = git.merge("master -m \"merged identical change from master\"") log = git.log() self.assertTrue("identical change from master" in log) except git.GrapeGitError as error: self.handleGitError(error) # Second, test that a merge that should result in a conflict throws an appropriate GrapeGitError exception. try: git.checkout("master") f2name = os.path.join(self.repo,"f2") writeFile3(f2name) git.add(f2name) git.commit("-m \"added f2\"") git.checkout("testMerge/tmp1") writeFile2(f2name) git.add(f2name) git.commit("-m \"added f2 in tmp branch\"") git.merge("master -m \"merged master branch into testmerge/tmp1\"") self.assertTrue(False,"Merge did not throw grapeGitError for conflict") except git.GrapeGitError as error: status = git.status() self.assertTrue("conflict" in status, "'conflict' not in status message %s" % status)