Class: Pod::Command::Patch::Migrate

Inherits:
Pod::Command::Patch show all
Defined in:
lib/pod/command/patch/migrate.rb

Instance Method Summary collapse

Methods inherited from Pod::Command::Patch

#patch_file, #patches_path

Instance Method Details

#clear_patches_folder_if_emptyObject



11
12
13
14
15
# File 'lib/pod/command/patch/migrate.rb', line 11

def clear_patches_folder_if_empty
  if Dir.empty?(patches_path)
    FileUtils.remove_dir(patches_path)
  end
end

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pod/command/patch/migrate.rb', line 17

def run
  UI.puts 'Migrating patches...'
  patches_dir = Pathname.new(Dir.pwd) + 'patches'
  if patches_dir.directory?
    patches = patches_dir.each_child.select { |c| c.to_s.end_with?('.diff') }
    patches.each do |p|
      # check if patch file has new format
      if p.to_s.include?('+')
        # do nothing
      else
        # rename patch file
        pod_name = p.basename('.diff').to_s
        UI.puts "Renaming #{pod_name}"

        pod_version = config.lockfile.version(pod_name)
        new_patch_name = p.to_s.gsub('.diff', "+#{pod_version}.diff")
        
        File.rename(p, new_patch_name)
      end
    end
  end
end