Class: Zewo::App

Inherits:
Thor
  • Object
show all
Defined in:
lib/zewo.rb

Defined Under Namespace

Classes: Repo

Instance Method Summary collapse

Instance Method Details

#checkoutObject



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/zewo.rb', line 294

def checkout
  if !options[:branch] && !options[:tag]
    puts 'Need to specify either --tag or --branch'.red
    return
  end

  Dir['*/'].each do |folder_name|
    folder_name = folder_name[0...-1]
    matched = `cd #{repo.name} && git tag`
              .split("\n")
              .select { |t| t.start_with?(options[:tag]) }
              .last if options[:tag]
    matched = options[:branch] if options[:branch]

    if matched
      silent_cmd("cd #{folder_name} && git checkout #{matched}")
      puts "Checked out #{folder_name} at #{matched}".green
    else
      puts "No matching specifiers for #{folder_name}".red
    end
  end
end

#clone_osx_devObject



351
352
353
354
355
356
357
358
359
360
361
362
363
364
# File 'lib/zewo.rb', line 351

def clone_osx_dev
  puts 'Cloning repositories...'
  each_osx_whitelisted_repo_async do |repo|
    unless File.directory?(repo.name)
      print "Cloning #{repo.data['organization']}/#{repo.name}...".green + "\n"
      silent_cmd("git clone #{repo.data['clone_url']}")

      cloned_name = repo.data['clone_url'].split('/').last
      if cloned_name.end_with?('-OSX')
        FileUtils.mv cloned_name, cloned_name[0...-4]
      end
    end
  end
end

#initObject



337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/zewo.rb', line 337

def init
  use_ssh = prompt('Clone using SSH?')

  each_repo_async do |repo|
    print "Checking #{repo.name}..." + "\n"
    unless File.directory?(repo.name)
      print "Cloning #{repo.name}...".green + "\n"
      silent_cmd("git clone #{repo.data[use_ssh ? 'clone_url' : 'ssh_url']}")
    end
  end
  puts 'Done!'
end

#make_osx_dev_projectsObject



367
368
369
370
# File 'lib/zewo.rb', line 367

def make_osx_dev_projects
  each_osx_whitelisted_repo(&:configure_xcode_project)
  each_osx_whitelisted_repo(&:build_dependencies)
end

#make_projectsObject



331
332
333
334
# File 'lib/zewo.rb', line 331

def make_projects
  each_code_repo(&:configure_xcode_project)
  each_code_repo(&:build_dependencies)
end

#pullObject



318
319
320
321
322
323
324
325
326
327
328
# File 'lib/zewo.rb', line 318

def pull
  print "Updating all repositories...\n"
  each_code_repo_async do |repo|
    if uncommited_changes?(repo.name)
      print "Uncommitted changes in #{repo.name}. Not updating.".red + "\n"
      next
    end
    system("cd #{repo.name}; git pull")
  end
  puts 'Done!'
end

#setup_osx_devObject



374
375
376
377
378
379
380
381
382
# File 'lib/zewo.rb', line 374

def setup_osx_dev()
  clone_osx_dev()

  invoke 'checkout', [], :tag => options[:version]

  checkout_modulemap_versions()

  make_osx_dev_projects()
end

#statusObject



270
271
272
273
274
275
276
277
278
# File 'lib/zewo.rb', line 270

def status
  each_code_repo do |repo|
    str = repo.name
    str = uncommited_changes?(repo.name) ? str.red : str.green
    tag = `cd #{repo.name}; git describe --abbrev=0 --tags` || 'No tag'
    str += " (#{tag})"
    puts str.delete("\n")
  end
end

#tag(tag) ⇒ Object



281
282
283
284
285
286
287
288
289
# File 'lib/zewo.rb', line 281

def tag(tag)
  each_code_repo do |repo|
    should_tag = prompt("create tag #{tag} in #{repo.name}?")
    if should_tag
      silent_cmd("cd #{repo.name} && git tag #{tag}")
      puts repo.name.green
    end
  end
end