示例#1
0
 def post(self, username, repo, pullrequest):
     repo = parse_url(username, repo)
     if repo:
         request = PullRequest.mc_get(pullrequest)
         if request:
             # TODO: Privileges
             request.merge()
             return self.redirect(request.to_repo.link)
     raise tornado.web.HTTPError(404)
示例#2
0
 def get(self, username, repo, pullrequest):
     repo = parse_url(username, repo)
     if repo:
         request = PullRequest.mc_get(pullrequest)
         if request:
             return self.render("/app/repo/pullrequest.html", request=request)
         else:
             return self.redirect(repo.link)
     raise tornado.web.HTTPError(404)
示例#3
0
    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)