Class: StudFinder::Diff
- Inherits:
-
Object
- Object
- StudFinder::Diff
- Defined in:
- lib/stud_finder/diff.rb
Overview
Resolves the set of files changed on HEAD relative to the merge-base with a base ref (e.g. origin/staging), as repo-root-relative paths that match the form FileCollector emits. Used to filter output down to a PR's touched files WITHOUT narrowing the analysis population — scoring still runs against the full repo, so fan_in and percentiles stay correct.
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #changed_paths ⇒ Object
-
#initialize(repo_path:, base_ref:) ⇒ Diff
constructor
A new instance of Diff.
- #validate_ref! ⇒ Object
Constructor Details
#initialize(repo_path:, base_ref:) ⇒ Diff
Returns a new instance of Diff.
14 15 16 17 |
# File 'lib/stud_finder/diff.rb', line 14 def initialize(repo_path:, base_ref:) @repo_path = File.(repo_path) @base_ref = base_ref end |
Instance Method Details
#changed_paths ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/stud_finder/diff.rb', line 23 def changed_paths verify_ref! stdout, stderr, status = Open3.capture3( 'git', '-C', @repo_path, 'diff', '--name-only', '--diff-filter=d', "#{@base_ref}...HEAD" ) raise Error, diff_error(stderr) unless status.success? stdout.each_line.map(&:strip).reject(&:empty?) rescue Errno::ENOENT raise Error, 'Error: git not found in PATH.' end |
#validate_ref! ⇒ Object
19 20 21 |
# File 'lib/stud_finder/diff.rb', line 19 def validate_ref! verify_ref! end |