class Codingapi::CodingapiApp

Your code goes here…

Public Instance Methods

get_git_info() click to toggle source
# File lib/codingapi.rb, line 57
def get_git_info()
  # 获取coding 仓库信息
  @coding_json = get_all_coding_repo(username:@codig_user_name, token:@codig_token)

  @coding_json_file = File.join(@move_dir, "coding_git.json")
  File.open(@coding_json_file, "w") do |f|
    f.write(JSON.pretty_generate(@coding_json))
  end

  # 转化gitee 仓库信息
  @gitee_json = produce_gitee_info(origin_josn:@coding_json)
  @gitee_json_file = File.join(@move_dir, "gitee_git.json")
  File.open(@gitee_json_file, "w") do |f|
    f.write(JSON.pretty_generate(@gitee_json))
  end

end
init_info() click to toggle source
# File lib/codingapi.rb, line 19
def init_info
  

  if @codig_user_name.nil?
    @codig_user_name = ask('Input codig_user_name: ') || nil
  end

  if @codig_token.nil?
    @codig_token = ask('Input codig_token: ') || nil
  end
  if @gitee_user_name.nil?
    @gitee_user_name = ask('Input gitee_user_name: ') || nil
  end
  if @gitee_token.nil?
    @gitee_token = ask('Input gitee_token: ') || nil
  end

  puts "codig_user_name = #{@codig_user_name}"
  puts "codig_token = #{@codig_token}"
  puts "gitee_user_name = #{@gitee_user_name}"
  puts "gitee_token = #{@gitee_token}"


  @work_dir = File.join(Dir.pwd, "work_dir")
  if !File.exist?(@work_dir)
    FileUtils.mkdir(@work_dir)
  end
  @move_dir = File.join(@work_dir, "move_git")
  @modify_dir = File.join(@work_dir, "modify_git")
  if !File.exist?(@move_dir)
    FileUtils.mkdir(@move_dir)
  end
  if !File.exist?(@modify_dir)
    FileUtils.mkdir(@modify_dir)
  end
  
end
modify_git() click to toggle source
# File lib/codingapi.rb, line 105
def modify_git()
  @modify_json = []
  @unmodify_json = []
  if !@gitee_json.nil? && @gitee_json.length > 0
    for item in @gitee_json do
      # begin
          if modify_git_repo_exe(username:@gitee_user_name, token:@gitee_token, item_json:item, path:@modify_dir)
            @modify_json.push(item)
          else
            @unmodify_json.push(item)
          end
      # rescue => exception
      #     @unmodify_json.push(item)
      # end
    end
  end


  @modify_json_file = File.join(@modify_dir, "modify_git.json")
  File.open(@modify_json_file, "w") do |f|
    f.write(JSON.pretty_generate(@modify_json))
  end

  @unmodify_json_file = File.join(@modify_dir, "unmodify_git.json")
  File.open(@unmodify_json_file, "w") do |f|
    f.write(JSON.pretty_generate(@unmodify_json))
  end
  
end
move_git() click to toggle source
# File lib/codingapi.rb, line 75
def move_git()
  @exception_json = []
  @sucess_json = []
  if !@gitee_json.nil? && @gitee_json.length > 0
    for item in @gitee_json do
      begin
        if move_git_repo_exe(username:@gitee_user_name, token:@gitee_token, item_json:item, path:@move_dir)
          @sucess_json.push(item)
        else
          @exception_json.push(item)
        end
        
      rescue => exception
        @exception_json.push(item)
      end
    end
  end

  @exception_json_file = File.join(@move_dir, "exception_git.json")
  File.open(@exception_json_file, "w") do |f|
    f.write(JSON.pretty_generate(@exception_json))
  end

  @sucess_json_file = File.join(@move_dir, "sucess_git.json")
  File.open(@sucess_json_file, "w") do |f|
    f.write(JSON.pretty_generate(@sucess_json))
  end

end
run(argv) click to toggle source
# File lib/codingapi.rb, line 135
def run(argv)

  puts Codingapi::VERSION

  init_info()
  get_git_info()
  move_git()
  modify_git()


  # api = Giteeinterface.new(username:@gitee_user_name, token:@gitee_token)
  # puts  api.username
  # pinpods   iosopencode  iosideaapp  iosmainapp
  # api.create_repo(owner:"iosmainapp", repo_name:"test01")
  # repo_info = api.get_repo_info(owner:"iosmainapp", repo_name:"test01")
  # puts repo_info['ssh_url']

  # res = api.get_repo_breanch_info(owner:"iosmainapp", repo_name:"LiteGZ")
  # puts res
  # res = api.get_orgs_repo_list(org:"iosmainapp", page:1, per_page:2)
  # puts JSON.pretty_generate(res)
end