Created
September 4, 2014 10:35
-
-
Save andywenk/74da349b0ae49448b366 to your computer and use it in GitHub Desktop.
rake task to compare remote and local git branches
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
task :compare_remote_and_local_branch do | |
sh "git remote update" | |
current_branch = `git rev-parse --abbrev-ref HEAD` | |
local_commit_hash = `git rev-parse HEAD` | |
remote_commit_hash = `git rev-parse origin/#{current_branch}` | |
print "#{Term::ANSIColor.green}[INFO]: branch: #{current_branch}#{Term::ANSIColor.reset}" | |
print "#{Term::ANSIColor.green}[INFO]: local commit hash: #{local_commit_hash}#{Term::ANSIColor.reset}" | |
print "#{Term::ANSIColor.green}[INFO]: remote commit hash: #{remote_commit_hash}#{Term::ANSIColor.reset}" | |
if local_commit_hash == remote_commit_hash | |
puts "#{Term::ANSIColor.green}[STOP]: local und remote sind gleich.#{Term::ANSIColor.reset}" | |
exit() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment