| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  | class Tap | 
					
						
							|  |  |  |   module Compat | 
					
						
							|  |  |  |     def initialize(user, repo) | 
					
						
							|  |  |  |       super | 
					
						
							| 
									
										
										
										
											2018-05-15 14:56:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  |       return unless user == "caskroom" | 
					
						
							| 
									
										
										
										
											2018-05-15 14:56:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-25 16:22:46 +02:00
										 |  |  |       old_initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{repo_var}" | 
					
						
							|  |  |  |       old_current_revision_var = "HOMEBREW_UPDATE_AFTER#{repo_var}" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  |       new_user = "Homebrew" | 
					
						
							|  |  |  |       new_repo = (repo == "cask") ? repo : "cask-#{repo}" | 
					
						
							| 
									
										
										
										
											2018-05-15 16:07:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  |       old_name = name | 
					
						
							|  |  |  |       old_path = path | 
					
						
							| 
									
										
										
										
											2018-05-29 10:54:57 +02:00
										 |  |  |       old_remote = path.git_origin | 
					
						
							| 
									
										
										
										
											2018-05-15 16:07:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-25 22:47:31 +02:00
										 |  |  |       clear_cache | 
					
						
							| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  |       super(new_user, new_repo) | 
					
						
							| 
									
										
										
										
											2018-05-15 16:07:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-29 10:54:57 +02:00
										 |  |  |       return unless old_path.directory? | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-25 16:22:46 +02:00
										 |  |  |       new_initial_revision_var = "HOMEBREW_UPDATE_BEFORE#{repo_var}" | 
					
						
							|  |  |  |       new_current_revision_var = "HOMEBREW_UPDATE_AFTER#{repo_var}" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       ENV[new_initial_revision_var] ||= ENV[old_initial_revision_var] | 
					
						
							|  |  |  |       ENV[new_current_revision_var] ||= ENV[old_current_revision_var] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  |       new_name = name | 
					
						
							|  |  |  |       new_path = path | 
					
						
							|  |  |  |       new_remote = default_remote | 
					
						
							| 
									
										
										
										
											2018-05-15 16:07:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  |       ohai "Migrating tap #{old_name} to #{new_name}..." if $stdout.tty? | 
					
						
							| 
									
										
										
										
											2018-05-15 16:07:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-29 10:54:57 +02:00
										 |  |  |       if old_path.git? | 
					
						
							|  |  |  |         puts "Changing remote from #{old_remote} to #{new_remote}..." if $stdout.tty? | 
					
						
							|  |  |  |         old_path.git_origin = new_remote | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  |       puts "Moving #{old_path} to #{new_path}..." if $stdout.tty? | 
					
						
							|  |  |  |       path.dirname.mkpath | 
					
						
							|  |  |  |       FileUtils.mv old_path, new_path | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-05-15 14:56:28 +02:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-17 19:17:41 +02:00
										 |  |  |   prepend Compat | 
					
						
							| 
									
										
										
										
											2018-05-15 14:56:28 +02:00
										 |  |  | end |