Class: Pod::Command::Dist

Inherits:
Pod::Command show all
Extended by:
Executable
Includes:
ProjectDirectory, RepoUpdate
Defined in:
lib/cocoapods-dist/command/dist.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Dist

Returns a new instance of Dist.



30
31
32
33
34
35
# File 'lib/cocoapods-dist/command/dist.rb', line 30

def initialize(argv)
  @tag = argv.flag?('tag', true)
  @commit = argv.flag?('commit', false)
  @name = argv.shift_argument
  super
end

Class Method Details

.optionsObject



23
24
25
26
27
28
# File 'lib/cocoapods-dist/command/dist.rb', line 23

def self.options
  [
    ['--tag', 'show tags only'],
    ['--commit', 'show all addtion commits'],
  ].concat(super)
end

Instance Method Details

#runObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cocoapods-dist/command/dist.rb', line 42

def run

  validate!

  #clone module to cache dir && fetch newest log
  cloneToCache
  fetchGit

  #fetch updates
  outdated = Pod::Command::Outdated.parse([])
  updates = outdated.public_updates
  updates = updates.select {|subArr| subArr[0] == @name} unless updates.empty?

  if updates.empty?
    UI.puts 'No pod updates are available.'.yellow
  else
    UI.section 'The color indicates what happens when you run `pod update`' do
      UI.puts "#{'<green>'.green}\t - Will be updated to the newest version"
      UI.puts "#{'<blue>'.blue}\t - Will be updated, but not to the newest version because of specified version in Podfile"
      UI.puts "#{'<red>'.red}\t - Will not be updated because of specified version in Podfile"
      UI.puts ''
    end if ansi_output?
    UI.section "The following pod update #{@name} are available:" do
      updates.each do |(name, from_version, matching_version, to_version)|
        color = :blue
        if matching_version == to_version
          color = :green
        elsif from_version == matching_version
          color = :red
        end
        UI.puts "- #{name} #{from_version.to_s.send(color)} -> #{matching_version.to_s.send(color)} " \
        "(latest version #{to_version.to_s})" # rubocop:disable Lint/StringConversionInInterpolation

        unless matching_version.version.empty? || from_version.version.empty?
          if @commit 
            commit_sha_start = git('rev-parse',from_version).chomp
            commit_sha_end = git('rev-parse',matching_version).chomp
            log = git('log','--pretty=format:"%h %s"',"#{commit_sha_start}...#{commit_sha_end}").chomp
            UI.puts "#{log}" 
          else
            Dir.chdir(env_git) { 
              tags = (git! ['tag']).split("\n")                
              tags.each do |tag|
                if versionGreat(tag.to_s,from_version.to_s) && versionGreatOrEqual(matching_version.to_s,tag.to_s)
                  commit_sha = git('rev-parse',tag).chomp
                  log = git('log','--pretty=format:"%s"','-n 1',commit_sha).chomp
                  # log = git('show','--quiet','--pretty=format:"%s"',commit_sha)
                  UI.puts "[#{tag}]: ".send(color) + "#{log}"
                end
              end
            } 
          end
        end

      end 
    end
  end
end

#validate!Object



37
38
39
40
# File 'lib/cocoapods-dist/command/dist.rb', line 37

def validate!
  super
  help! 'A Pod name is required.' unless @name
end