def test_merge_pull_request(self): repo1 = self.setup_repo() repo2 = self.setup_clone(repo1) content = "this is s a dsafsdf" pull_request = PullRequest() pull_request.from_repo_id = repo2.id pull_request.from_branch = 'master' pull_request.to_repo_id = repo1.id pull_request.to_branch = 'master' pull_request.user_id = repo2.owner_id with mkdtemp() as work_path: with chdir(work_path): check_call(('git clone %s %s'%(repo1.clone_addr, work_path)).split()) with open(join(work_path, 'orig'), 'w') as f: f.write(content) check_call('git add .'.split()) check_call('git commit -m"f" -a'.split()) check_call('git push origin master'.split()) with mkdtemp() as work_path: with chdir(work_path): check_call(('git clone %s %s'%(repo2.clone_addr, work_path)).split()) with open(join(work_path, 'new_file'), 'w') as f: f.write(content) check_call('git add .'.split()) check_call('git commit -m"f" -a'.split()) check_call('git push origin master'.split()) pull_request.merge() with mkdtemp() as work_path: with chdir(work_path): check_call(('git clone %s %s'%(repo1.clone_addr, work_path)).split()) with open("new_file") as f: self.assertEqual(f.read(), content)
def create_new_repo(user, name, desc): new_repo = Repo() new_repo.owner_id = user.id new_repo.name = name new_repo.desc = desc check_call(('git init %s --bare'%new_repo.repo_path).split()) with mkdtemp() as temp: check_call(['git','clone',new_repo.repo_path, temp]) with chdir(temp): check_call(['touch','README']) check_call(['git', 'add', '.']) check_call(['git','commit','-m','first commit']) check_call(['git','push','origin', 'master']) new_repo.save() return new_repo