Skip to content
This repository has been archived by the owner on Oct 17, 2019. It is now read-only.

Commit

Permalink
Added ahead and behind indicators to switchall
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhijay authored and cmoesel committed Aug 17, 2018
1 parent 819a33d commit ce1cad3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions switch-all-branches
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/bin/bash

# This tool helps manage the different SHR branches
# It is recommended you alias it to a shorter command to ease use.
# I have it aliased in my git config as:
# [alias]
# sa = !bash switchAllBranches
# to easily use it as "git sa feature-branch"

RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;36m'
Expand Down Expand Up @@ -146,7 +154,10 @@ function git_branches()
#check if repo is out of sync with remote
remote=$(cd $sub; git branch -a | grep remotes | grep -s -m 1 $($curr_br) 2>/dev/null | tr -d '*'' ' )
if [[ $remote != "" && -n $(cd $sub; git diff --shortstat $($curr_br)..remotes/origin/$($curr_br)) ]]; then
changed="${changed}${YLW}*${NC}";
ahead=$(cd $sub; git rev-list --left-right --count $($curr_br)...origin/$($curr_br) | cut -f 1);
behind=$(cd $sub; git rev-list --left-right --count $($curr_br)...origin/$($curr_br) | cut -f 2);

changed="${changed}${YLW}*${DIM} [$GREEN${ahead}${RED}${behind}${DIM}]$NC";
fi

# #adjust spacing if needed
Expand All @@ -165,4 +176,4 @@ function git_branches()
echo
}

git_branches
git_branches

0 comments on commit ce1cad3

Please sign in to comment.