Class: Rwm::Commands::Affected

Inherits:
Object
  • Object
show all
Defined in:
lib/rwm/commands/affected.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Affected

Returns a new instance of Affected.



8
9
10
11
12
13
# File 'lib/rwm/commands/affected.rb', line 8

def initialize(argv)
  @argv = argv
  @committed_only = false
  @base_branch = nil
  parse_options
end

Instance Method Details

#runObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rwm/commands/affected.rb', line 15

def run
  workspace = Workspace.find
  graph = DependencyGraph.load(workspace)
  detector = AffectedDetector.new(workspace, graph, committed_only: @committed_only, base_branch: @base_branch)

  affected = detector.affected_packages
  directly_changed = detector.directly_changed_packages

  if affected.empty?
    puts "No packages affected."
    return 0
  end

  puts "Base branch: #{detector.base_branch}"
  puts "Affected packages (#{affected.size}):"
  puts

  affected.each do |pkg|
    marker = directly_changed.include?(pkg) ? "(changed)" : "(dependent)"
    puts "  #{pkg.name} #{marker}"
  end

  0
end