Last active
March 22, 2018 03:29
-
-
Save chyld/4644402 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# encoding: utf-8 | |
branches = STDIN.read.chomp | |
if !branches.empty? | |
branch = branches.split("\n").map(&:strip)[0].split(' ').map(&:strip)[-1] | |
second_line = branches.split("\n").map(&:strip)[1] | |
is_clean = second_line == "nothing to commit, working directory clean" | |
if !branches.empty? | |
if is_clean | |
puts " ✓ #{branch}" | |
else | |
puts "\e[0;31m ✗ #{branch}" | |
end | |
end | |
end |
With git version 2.5.3. I had to modify this slightly to be
last_line = branches.split("\n").map(&:strip).last
is_clean = last_line == "nothing to commit, working directory clean"
hey @gdomingu , thanks! I know this is 3 years late, but this little ruby script is awesome, and I was wondering why it stopped working :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you change line 11 to
it'll be red and more visible.
WORD