-
Notifications
You must be signed in to change notification settings - Fork 72
Processing pull requests
markstory edited this page Jan 30, 2013
·
4 revisions
This page is a brain dump of how a pull request should be processed and errors aggregated:
- Web process receives hook.
- Background job is queued for the repository + user + pull request number.
- Status code is returned based on job queue success.
-
.lintrc
file is downloaded for the queued repo.- If there is no
.lintrc
file an error is logged and job is completed as a failure.
- If there is no
-
.lintrc
file is parsed into a ReviewConfig object. - A
Review
object is created. It gives an internal API for adding problems. It is responsible for converting problem output from tools into comments on the pull request. - Using the user, repo & pull request number the changed files are fetched from github.
- The patch keys for each changed file are processed. A
DiffCollection
object is created. This object gives accessors for reading filenames, lines changed, and commits lines changed in. - The merge head repository is cloned/updated.
- Files are cloned into the WORKSPACE dir. And stored by $user/$repo/$prnumber.
- If a repo does not exist it is cloned.
- If a repo does exist it is updated, and its HEAD is moved to the merge head from the pull request.
- The list of changed files is prepared from the
DiffCollection
- The configured tools for repository are constructed.
- Each tool is run for the changed files.
- Each tool filters the fileset to include only those it can handle using
match_file()
. - The underlying tool command is run and output is parsed.
- Problems found in tool output are added to the review with
review.add_problem(file, line, message)
.
- Each tool filters the fileset to include only those it can handle using
- The review loads existing comments for the pull request.
- New problems are compared to existing ones. If a problem matches the file, line, message of a previous comment, the new comment is discarded.
TODO FINISH
- New errors/comments are checked against the existing comment to prevent duplicates. Each new error is compared to the commit/file/line of existing comments and if the content matches a the error is discarded as a comment already exists.
- Once the new comments have been distilled. New comments are created using the commit/file/line.