Skip to content

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:

Incoming jobs

  • Web process receives hook.
  • Background job is queued for the repository + user + pull request number.
  • Status code is returned based on job queue success.

Processing jobs

  • .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.
  • .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 repo's basepath inside the workspace is appended to each file.
  • 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).
  • 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.
  • Once the new comments have been filtered. New comments are created using the by getting the commit for each file in the DiffCollection + file/line.
Clone this wiki locally