def _pep8ify(request, data, config): data["target_repo_fullname"] = data["pull_request"]["head"]["repo"][ "full_name"] data["target_repo_branch"] = data["pull_request"]["head"]["ref"] data["results"] = {} # Check if the fork of the target repo exists # If yes, then delete it helpers.delete_if_forked(data) # Fork the target repository helpers.fork_for_pr(data) # Update the fork description. This helps in fast deleting it helpers.update_fork_desc(data) # Create a new branch for the PR helpers.create_new_branch(data) # Fix the errors in the files helpers.autopep8ify(data, config) # Commit each change onto the branch helpers.commit(data) # Create a PR from the branch to the target repository helpers.create_pr(data) comment = "Here you go with [the Pull Request]({}) ! The fixes are " \ "suggested by [autopep8](https://github.com/hhatto/autopep8).\n\n" if data["reviewer"] == data["author"]: # Both are the same person comment += "@{} " comment = comment.format(data["pr_url"], data["reviewer"]) else: comment += "@{} @{} " comment = comment.format(data["pr_url"], data["reviewer"], data["author"]) auth = (os.environ["BOT_USERNAME"], os.environ["BOT_PASSWORD"]) query = "https://api.github.com/repos/{}/issues/{}/comments" query = query.format(data["repository"], str(data["pr_number"])) response = requests.post(query, json={"body": comment}, auth=auth) data["comment_response"] = response.json() js = json.dumps(data) return Response(js, status=200, mimetype='application/json')
def _pep8ify(ghrequest, config): ghrequest.target_repo_fullname = ghrequest.pull_request["head"]["repo"][ "full_name"] ghrequest.target_repo_branch = ghrequest.pull_request["head"]["ref"] ghrequest.results = {} # Check if the fork of the target repo exists # If yes, then delete it helpers.delete_if_forked(ghrequest) # Fork the target repository helpers.fork_for_pr(ghrequest) # Update the fork description. This helps in fast deleting it helpers.update_fork_desc(ghrequest) # Create a new branch for the PR helpers.create_new_branch(ghrequest) # Fix the errors in the files helpers.autopep8ify(ghrequest, config) # Commit each change onto the branch helpers.commit(ghrequest) # Create a PR from the branch to the target repository helpers.create_pr(ghrequest) comment = "Here you go with [the Pull Request]({}) ! The fixes are " \ "suggested by [autopep8](https://github.com/hhatto/autopep8).\n\n" if ghrequest.reviewer == ghrequest.author: # Both are the same person comment += "@{} " comment = comment.format(ghrequest.pr_url, ghrequest.reviewer) else: comment += "@{} @{} " comment = comment.format(ghrequest.pr_url, ghrequest.reviewer, ghrequest.author) query = "/repos/{}/issues/{}/comments" query = query.format(ghrequest.repository, str(ghrequest.pr_number)) response = utils.query_request(query, method='POST', json={"body": comment}) ghrequest.comment_response = response.json() return utils.Response(ghrequest)
def _pep8ify(request, data, config): data["target_repo_fullname"] = request.json["pull_request"]["head"]["repo"]["full_name"] data["target_repo_branch"] = request.json["pull_request"]["head"]["ref"] data["results"] = {} # Check if the fork of the target repo exists # If yes, then delete it helpers.delete_if_forked(data) # Fork the target repository helpers.fork_for_pr(data) # Update the fork description. This helps in fast deleting it helpers.update_fork_desc(data) # Create a new branch for the PR helpers.create_new_branch(data) # Fix the errors in the files helpers.autopep8ify(data, config) # Commit each change onto the branch helpers.commit(data) # Create a PR from the branch to the target repository helpers.create_pr(data) js = json.dumps(data) return Response(js, status=200, mimetype='application/json')