Guest User

Untitled

a guest
Apr 21st, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/bin/env ruby -w
  2.  
  3. # Pull remote changes for several directories at once
  4. # if they are git directories.
  5. #
  6. # AUTHOR: Geoffrey Grosenbach
  7. # April 28, 2009
  8. #
  9. # USAGE:
  10. #
  11. # gitup repos/*
  12.  
  13. require "optparse"
  14.  
  15. options = {
  16. :recurse => false,
  17. :verbose => false,
  18. }
  19.  
  20. ARGV.options do |opts|
  21. opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [OPTIONS] [DIRECTORY]"
  22.  
  23. opts.separator ""
  24. opts.separator "Common Options:"
  25.  
  26. opts.on( "-h", "--help",
  27. "Show this message." ) do
  28. puts opts
  29. exit
  30. end
  31. opts.on( "-r", "--recurse",
  32. "Recurse into subdirectories, looking for .git" ) do
  33. options[:recurse] = true
  34. end
  35. opts.on( "-v", "--verbose",
  36. "Output extra info." ) do
  37. options[:verbose] = true
  38. end
  39.  
  40. begin
  41. opts.parse!
  42. rescue
  43. puts opts
  44. exit
  45. end
  46. end
  47.  
  48. dirs = ARGV.first ? ARGV : [options[:recurse] ? './**/*' : './*']
  49.  
  50. Dir[*dirs].each do |project|
  51. if File.exist?(File.join(project, '.git'))
  52. puts "== Updating #{project}"
  53. system "cd #{project} && git pull && git --no-pager status"
  54. else
  55. puts "Skipping: #{project}" if options[:verbose]
  56. end
  57. end
Add Comment
Please, Sign In to add comment