class Monolith::Generator
Public Class Methods
new(monolith)
click to toggle source
# File lib/monolith/generator.rb 8 def initialize(monolith) 9 @monolith = monolith 10 end
Public Instance Methods
clone()
click to toggle source
# File lib/monolith/generator.rb 12 def clone 13 repositories.each do |repo| 14 log("Cloning repository #{repo.name.blue}") 15 repo.clone 16 end 17 end
generate()
click to toggle source
# File lib/monolith/generator.rb 19 def generate 20 clone 21 fetch_all_remotes 22 run_after_clone_hooks 23 create_monolith 24 add_remotes_to_monolith 25 prepare_branches_for_merge 26 merge_branches_into_monolith 27 remove_remotes_from_monolith 28 checkout_master_on_monolith 29 run_after_generate_hooks 30 end
Private Instance Methods
add_remotes_to_monolith()
click to toggle source
# File lib/monolith/generator.rb 63 def add_remotes_to_monolith 64 repositories.each do |repo| 65 log("Adding remote #{repo.name.blue} to monolith") 66 @monolith.remote(repo).add 67 end 68 end
branches()
click to toggle source
# File lib/monolith/generator.rb 104 def branches 105 @branches ||= filtered_branches.sort 106 end
checkout_master_on_monolith()
click to toggle source
# File lib/monolith/generator.rb 99 def checkout_master_on_monolith 100 log("Checking out monolith master branch") 101 @monolith.checkout_master 102 end
create_monolith()
click to toggle source
# File lib/monolith/generator.rb 51 def create_monolith 52 log("Generating monolith #{name.red}") 53 @monolith.create 54 end
fetch_all_remotes()
click to toggle source
# File lib/monolith/generator.rb 56 def fetch_all_remotes 57 repositories.each do |repo| 58 log("Fetching #{repo.name.blue} remotes from #{repo.url.yellow}") 59 repo.fetch 60 end 61 end
filtered_branches()
click to toggle source
# File lib/monolith/generator.rb 108 def filtered_branches 109 unsorted_branches.select do |branch| 110 @monolith.branch?(branch) 111 end 112 end
log_prefix()
click to toggle source
# File lib/monolith/generator.rb 122 def log_prefix 123 "==> ".green 124 end
merge_branches_into_monolith()
click to toggle source
# File lib/monolith/generator.rb 81 def merge_branches_into_monolith 82 log("Merging #{branches.size.to_s.yellow} total branches") 83 84 repositories.each do |repo| 85 branches.each do |branch| 86 log("Merging #{repo.name.blue} branch #{branch.light_magenta} or master") 87 @monolith.merge(repo, branch) 88 end 89 end 90 end
prepare_branches_for_merge()
click to toggle source
# File lib/monolith/generator.rb 70 def prepare_branches_for_merge 71 repositories.each do |repo| 72 repo.branches.each do |branch| 73 if @monolith.branch?(branch.name) 74 log("Preparing #{repo.name.blue} branch #{branch.name.light_magenta}") 75 repo.prepare(branch) 76 end 77 end 78 end 79 end
remove_remotes_from_monolith()
click to toggle source
# File lib/monolith/generator.rb 92 def remove_remotes_from_monolith 93 repositories.each do |repo| 94 log("Removing remote #{repo.name.blue} from monolith") 95 @monolith.remote(repo).remove 96 end 97 end
run_after_clone_hooks()
click to toggle source
# File lib/monolith/generator.rb 34 def run_after_clone_hooks 35 @monolith.config.after_clone_hooks.each do |hook| 36 run_hook(hook) 37 end 38 end
run_after_generate_hooks()
click to toggle source
# File lib/monolith/generator.rb 40 def run_after_generate_hooks 41 @monolith.config.after_generate_hooks.each do |hook| 42 run_hook(hook) 43 end 44 end
run_hook(hook)
click to toggle source
# File lib/monolith/generator.rb 46 def run_hook(hook) 47 log("Running hook #{hook.inspect}") 48 system(hook, @monolith.config.path, *branches) 49 end
unsorted_branches()
click to toggle source
# File lib/monolith/generator.rb 114 def unsorted_branches 115 repositories.each_with_object(Set.new) do |repo, branches| 116 repo.branches.each do |branch| 117 branches << branch.name 118 end 119 end 120 end