Guest User

Untitled

a guest
May 26th, 2018
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #! /usr/bin/env ruby
  2. #
  3. # a simple script to setup a new github project locally
  4. #
  5. # usage: ghdir project-name
  6. #
  7.  
  8. dir = ARGV.shift || abort('ghdir (project-name)')
  9.  
  10. gitdir = File.expand_path(File.join('~', 'git'))
  11.  
  12. Dir.chdir(gitdir)
  13.  
  14. commands = <<-__
  15. mkdir #{ dir.inspect }
  16. cd #{ dir.inspect }
  17. git init
  18. echo #{ dir.inspect } >> README
  19. git add README
  20. git commit -m 'first commit'
  21. git remote add origin git@github.com:dojo4/#{ dir }.git
  22. git push origin master
  23. __
  24.  
  25. commands = commands.strip.split(%r/\n+/).map{|command| command.strip}
  26.  
  27. commands.each do |command|
  28. puts command
  29. system(command) or abort("#{ command } # failed with #{ $?.inspect }")
  30. end
  31.  
  32. END{
  33. exec("cd #{ dir.inspect }")
  34. }
Add Comment
Please, Sign In to add comment