Created
May 30, 2012 12:38
-
-
Save lucas-clemente/2836006 to your computer and use it in GitHub Desktop.
Git Sync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
require 'rainbow' | |
def exec_cmd(cmd, ignore_fail = false) | |
puts cmd.bright | |
if !system(cmd, :out => File.open(File::NULL, 'w')) | |
if ignore_fail | |
return 1 | |
else | |
puts "Command failed, aborting.".color(:red) | |
exit 1 | |
end | |
end | |
end | |
msg = (ARGV.length > 0) ? ARGV * ' ' : "Commit on #{Time.now}" | |
exec_cmd('git pull') | |
exec_cmd('git add .') | |
exec_cmd("git commit -am '#{msg}'", true) | |
exec_cmd("git push") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment