Class: Rwm::AffectedDetector
- Inherits:
-
Object
- Object
- Rwm::AffectedDetector
- Defined in:
- lib/rwm/affected_detector.rb
Instance Attribute Summary collapse
-
#base_branch ⇒ Object
readonly
Returns the value of attribute base_branch.
-
#graph ⇒ Object
readonly
Returns the value of attribute graph.
-
#workspace ⇒ Object
readonly
Returns the value of attribute workspace.
Instance Method Summary collapse
-
#affected_packages ⇒ Object
Returns packages directly changed + their transitive dependents.
-
#directly_changed_packages ⇒ Object
Just the directly changed packages (no dependents).
-
#initialize(workspace, graph, committed_only: false) ⇒ AffectedDetector
constructor
A new instance of AffectedDetector.
Constructor Details
#initialize(workspace, graph, committed_only: false) ⇒ AffectedDetector
Returns a new instance of AffectedDetector.
7 8 9 10 11 12 |
# File 'lib/rwm/affected_detector.rb', line 7 def initialize(workspace, graph, committed_only: false) @workspace = workspace @graph = graph @committed_only = committed_only @base_branch = detect_base_branch end |
Instance Attribute Details
#base_branch ⇒ Object (readonly)
Returns the value of attribute base_branch.
5 6 7 |
# File 'lib/rwm/affected_detector.rb', line 5 def base_branch @base_branch end |
#graph ⇒ Object (readonly)
Returns the value of attribute graph.
5 6 7 |
# File 'lib/rwm/affected_detector.rb', line 5 def graph @graph end |
#workspace ⇒ Object (readonly)
Returns the value of attribute workspace.
5 6 7 |
# File 'lib/rwm/affected_detector.rb', line 5 def workspace @workspace end |
Instance Method Details
#affected_packages ⇒ Object
Returns packages directly changed + their transitive dependents
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rwm/affected_detector.rb', line 15 def affected_packages changed_files = detect_changed_files directly_changed = map_files_to_packages(changed_files) # If root-level files changed (outside any package), all packages are affected root_files = changed_files.reject { |f| file_in_any_package?(f) } unless root_files.empty? return workspace.packages end # Collect transitive dependents of directly changed packages all_affected = Set.new(directly_changed.map(&:name)) directly_changed.each do |pkg| graph.transitive_dependents(pkg.name).each { |name| all_affected << name } end workspace.packages.select { |pkg| all_affected.include?(pkg.name) } end |
#directly_changed_packages ⇒ Object
Just the directly changed packages (no dependents)
35 36 37 38 |
# File 'lib/rwm/affected_detector.rb', line 35 def directly_changed_packages changed_files = detect_changed_files map_files_to_packages(changed_files) end |