I'd used JGit before but only barely, so the diff part took me longer than I wanted to admit.
Start by clarifying requirements and edge cases, then outline a modular design: use JGit to diff branches, parse the CSV into a map of file patterns to owners, and compute the owner with the most changed lines. Discuss trade-offs like exact vs. pattern matching and performance for large diffs.
Pro tip: Mention that you would cache the CSV data and use a trie or prefix tree for efficient file path matching, and that you'd handle binary files and renames gracefully. This shows you think about real-world robustness and performance.
Ask about the CSV format (e.g., columns for file path and owner), whether matching is exact or pattern-based, and how to handle files with no owner. Also consider binary files, renames, and large repositories.
Break the problem into three modules: a Git diff component using JGit to compare branches and list changed files with line counts, a CSV parser to load ownership data into a map, and a matcher that aggregates changes per owner and selects the top owner.
Use JGit's DiffCommand to compare the two branches, then iterate over DiffEntries to get changed files. For each file, compute the number of added and deleted lines using EditList or DiffFormatter.
Read the CSV using a library like OpenCSV or manual parsing, storing file patterns and owners. For each changed file, find the matching owner (exact or pattern) and accumulate the total changed lines per owner.
Determine the owner with the maximum total changed lines; if tie, use a secondary criterion like most files. Discuss performance optimizations (e.g., caching, parallel processing) and how to handle missing owners or ambiguous matches.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.