class DYAutomate::Command::Pod::Push

Public Class Methods

new(argv) click to toggle source

#要查询的lib名字 attr_accessor :name #查询结果lib信息 attr_accessor :info

Calls superclass method DYAutomate::Command::Pod::new
# File lib/DYAutomate/Command/Pod/push.rb, line 21
def initialize(argv)
  # @name = argv.shift_argument
  super
end

Public Instance Methods

run() click to toggle source
# File lib/DYAutomate/Command/Pod/push.rb, line 37
def run
  pp('push run ...',1)

  Dir.chdir(@path)
  new_v = get_spec_version

  isTagOk = true
  retry_time = 2

  #git 处理
  begin
    isTagOk = system "git add ."
    isTagOk = system "git commit -m \"修改版本号 ->#{new_v}\""
    isTagOk = system "git push"
    unless isTagOk
      retry_time.times{
         pp('retry push ...',1)
         isTagOk = system "git push"
         system 'sleep 2'
      }
    end

    if isTagOk
      isTagOk = system "git tag -a #{new_v} -m '升级tag'"
      isTagOk = system "git push --tags"
      unless isTagOk
         retry_time.times{
            pp('retry push tags ...',1)
            isTagOk = system "git push --tags"
            system 'sleep 2'
        }
      end
    end
  rescue
    isTagOk = false
    pp("Errror git --- #{@name} --- #{new_v}", 2)
  end

  if isTagOk
    #push 到repo仓库
    dy_update_repo

    pp('私有库repo ->' + @repoName,1)
    pp("环境变量 -->"+@env_str,1)

    isok = system "#{@env_str} pod repo push #{@repoName} \
      --sources='master',#{@repoName} \
      --use-libraries \
      --allow-warnings \
      --verbose"
    unless isok
      system "git reset --hard "
      system "git tag -d #{new_v}"
      system "git push origin -d #{new_v}"
    end
  end
end
validate!() click to toggle source
Calls superclass method DYAutomate::Command::Pod#validate!
# File lib/DYAutomate/Command/Pod/push.rb, line 26
def validate!
  super
  # unless @name
  #   help! 'need the lib `NAME`.'
  # end

  # unless existAtPools?
  #   help! "the podspec file is not exist at #{Dir.pwd}."
  # end
end