Beispiel #1
0
 def setUp(self):
     path1 = utils.get_temporary_location()
     path2 = utils.get_temporary_location()
     path2 = os.path.join(path2, "repo")
     self.repo1 = LocalRepository(path1)
     self.repo1.init()
     for i in range(10):
         with open(os.path.join(self.repo1.path, "file_%s.txt" % i), "wb") as output:
             print >>output, "This is file", i
     self.repo1.addAll()
     self.repo1.commit(message="init")
     self.repo2 = LocalRepository(path2)
     self.repo2.clone(self.repo1)
     self.assertTrue(os.path.isdir(self.repo2.path))
Beispiel #2
0
 def setUp(self):
     path1 = utils.get_temporary_location()
     path2 = utils.get_temporary_location()
     path2 = os.path.join(path2, "repo")
     self.repo1 = LocalRepository(path1)
     self.repo1.init()
     for i in range(10):
         with open(os.path.join(self.repo1.path, "file_%s.txt" % i),
                   "wb") as output:
             print >> output, "This is file", i
     self.repo1.addAll()
     self.repo1.commit(message="init")
     self.repo2 = LocalRepository(path2)
     self.repo2.clone(self.repo1)
     self.assertTrue(os.path.isdir(self.repo2.path))
Beispiel #3
0
 def testCloneModifyPushToBranch(self):
     new_repo = clone(self.repo, utils.get_temporary_location())
     branch = new_repo.createBranch('work')
     new_repo.checkout(branch)
     utils.commit_change(new_repo)
     new_repo.push(self.repo, fromBranch=branch, toBranch='work')
     self.assertTrue(self.repo.getBranchByName('work').getHead() == new_repo.getHead())
Beispiel #4
0
 def setUp(self):
     self.dirname = get_temporary_location()
     os.mkdir(self.dirname)
     status, output = commands.getstatusoutput("cd %s && git init && git commit -a -m init --allow-empty" % self.dirname)
     self.assertEqual(status, 0)
     status, init_hash = commands.getstatusoutput("cd %s && git rev-parse HEAD" % self.dirname)
     self.assertEqual(status, 0)
     self.initHash = init_hash.strip()
Beispiel #5
0
 def testCloneModifyPush(self):
     new_repo = LocalRepository(utils.get_temporary_location())
     new_repo.clone(self.repo)
     self.assertReposEqual(self.repo, new_repo)
     utils.commit_change(new_repo)
     new_repo.push()
     self.repo.resetHard()
     self.assertReposEqual(self.repo, new_repo)        
     utils.delete_repository(new_repo)
Beispiel #6
0
 def testCloneModifyPushToBranch(self):
     new_repo = clone(self.repo, utils.get_temporary_location())
     prev_branch = self.repo.getCurrentBranch()
     self.repo.checkout(self.repo.createBranch('temp'))
     branch = new_repo.createBranch('work')
     new_repo.checkout(branch)
     utils.commit_change(new_repo)
     new_repo.push(self.repo, fromBranch=branch, toBranch='work')
     self.repo.checkout(prev_branch)
     self.assertTrue(self.repo.getBranchByName('work').getHead() == new_repo.getHead())
Beispiel #7
0
 def setUp(self):
     self.dirname = get_temporary_location()
     os.mkdir(self.dirname)
     status, output = commands.getstatusoutput(
         "cd %s && git init && git commit -a -m init --allow-empty && git tag tag_name"
         % self.dirname)
     self.assertEqual(status, 0)
     status, init_hash = commands.getstatusoutput(
         "cd %s && git rev-parse HEAD" % self.dirname)
     self.assertEqual(status, 0)
     self.initHash = init_hash.strip()
Beispiel #8
0
 def testCloneModifyPush(self):
     new_repo = LocalRepository(utils.get_temporary_location())        
     new_repo.clone(self.repo)
     #checkout a different branch to comply with git 1.7.0
     prev_branch = self.repo.getCurrentBranch()
     self.repo.checkout(self.repo.createBranch('temp'))        
     self.assertReposEqual(self.repo, new_repo)
     utils.commit_change(new_repo)
     new_repo.push()
     self.repo.checkout(prev_branch)        
     self.assertReposEqual(self.repo, new_repo)        
     utils.delete_repository(new_repo)
Beispiel #9
0
 def testAddingRemotes(self):
     new_repo = LocalRepository(utils.get_temporary_location())
     new_repo.init()
     with open(os.path.join(new_repo.path, "some_file"), "wb") as f:
         print >> f, "new file"
     new_repo.addAll()
     new_repo.commit(message="initial change")
     REMOTE_NAME = 'remote'
     remote = new_repo.addRemote(REMOTE_NAME, self.repo.path)
     self.assertEquals(remote.name, REMOTE_NAME)
     self.assertEquals(remote.url, self.repo.path)
     self.assertFalse(new_repo.containsCommit(self.repo.getHead()))
     remote.fetch()
     remote.prune()
     self.assertTrue(new_repo.containsCommit(self.repo.getHead()))
     branches = list(remote.getBranches())
     self.assertTrue(len(branches) > 0)
     for branch in branches:
         self.assertTrue(type(branch in new_repo.getHead()) is bool)
Beispiel #10
0
 def testAddingRemotes(self):
     new_repo = LocalRepository(utils.get_temporary_location())
     new_repo.init()
     with open(os.path.join(new_repo.path, "some_file"), "wb") as f:
         print >> f, "new file"
     new_repo.addAll()
     new_repo.commit(message="initial change")
     REMOTE_NAME = 'remote'
     remote = new_repo.addRemote(REMOTE_NAME, self.repo.path)
     self.assertEquals(remote.name, REMOTE_NAME)
     self.assertEquals(remote.url, self.repo.path)
     self.assertFalse(new_repo.containsCommit(self.repo.getHead()))
     remote.fetch()
     remote.prune()
     self.assertTrue(new_repo.containsCommit(self.repo.getHead()))
     branches = list(remote.getBranches())
     self.assertTrue(len(branches) > 0)
     for branch in branches:
         self.assertTrue(type(branch in new_repo.getHead()) is bool)
Beispiel #11
0
 def setUp(self):
     self.dirname = get_temporary_location()
     os.mkdir(self.dirname)
     output = subprocess.check_output("cd %s && git init && git commit -a -m init --allow-empty && git tag tag_name" % self.dirname, shell=True).decode("utf-8")
     init_hash = subprocess.check_output("cd %s && git rev-parse HEAD" % self.dirname, shell=True).decode("utf-8")
     self.initHash = init_hash.strip()
Beispiel #12
0
 def setUp(self):
     self.dirname = get_temporary_location()
     self.repo = LocalRepository(self.dirname)
     self.assertFalse(os.path.exists(self.dirname))
     self.assertFalse(self.repo.isValid())
Beispiel #13
0
 def setUp(self):
     self.dirname = get_temporary_location()
     self.repo = LocalRepository(self.dirname)
     self.assertFalse(os.path.exists(self.dirname))
     self.assertFalse(self.repo.isValid())