Katkat

Assign Reviewers from Changed Files

StripeSoftware Engineer · Onsite

Last updated

This question evaluates proficiency with version control diffs, repository library APIs, file I/O and CSV parsing, and data aggregation to map changed files to their owners.

Write a Java program that helps automatically assign a code reviewer after a pull request is opened.

You are given:

  1. A local Git repository path.
  2. Two branch names: baseBranch and targetBranch.
  3. A CSV file that maps source files to file owners.

The program should:

  1. Use a Git library, such as JGit, to compare baseBranch and targetBranch.
  2. Produce the list of file paths that were changed between the two branches.
  3. Read the CSV file containing ownership information. Each row has the format:
file_path,owner

Example:

src/payments/ChargeService.java,alice
src/payments/RefundService.java,bob
src/common/JsonUtil.java,alice
  1. Count how many changed files are owned by each owner.
  2. Return the owner who owns the largest number of changed files.

If a changed file does not appear in the CSV file, ignore it. If there is a tie, return any one of the tied owners. If no changed file has an owner, return an empty result.