summaryrefslogtreecommitdiffstats
path: root/git-base.sh
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-08-06 09:49:57 +0100
committerMichael Allen <michael@michaelallen.io>2015-08-06 09:51:37 +0100
commit87c8f642278cf82e9c9011413624b64a878b23a9 (patch)
treed409f4cacd32c757fb511e5727aec554f3b05f08 /git-base.sh
parent14eae43ec9ba2bc7ee95a78cb6232464940730f5 (diff)
downloadgit-sonar-87c8f642278cf82e9c9011413624b64a878b23a9.tar.gz
git-sonar-87c8f642278cf82e9c9011413624b64a878b23a9.zip
Provide example of local commit difference
Diffstat (limited to 'git-base.sh')
-rwxr-xr-xgit-base.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/git-base.sh b/git-base.sh
index e60f9fc..aca271b 100755
--- a/git-base.sh
+++ b/git-base.sh
@@ -369,3 +369,29 @@ zsh_color_changes_status() {
fi
echo $changes
}
+
+zsh_color_local_commits() {
+ local ahead_arrow="%{$fg_bold[green]%}↑%{$reset_color%}"
+ local behind_arrow="%{$fg_bold[red]%}↓%{$reset_color%}"
+ local diverged_arrow="%{$fg_bold[yellow]%}⇵%{$reset_color%}"
+
+ local local_commits=""
+ if is_repo; then
+
+ if remote_branch="$(remote_branch_name)"; then
+ local_ahead="$(commits_ahead_of_remote "$remote_branch")"
+ local_behind="$(commits_behind_of_remote "$remote_branch")"
+ remote_ahead="$(remote_ahead_of_master "$remote_branch")"
+ remote_behind="$(remote_behind_of_master "$remote_branch")"
+
+ if [[ "$local_behind" -gt "0" && "$local_ahead" -gt "0" ]]; then
+ local_commits=" $local_behind$diverged_arrow$local_ahead"
+ elif [[ "$local_behind" -gt "0" ]]; then
+ local_commits=" $local_behind$behind_arrow"
+ elif [[ "$local_ahead" -gt "0" ]]; then
+ local_commits=" $local_ahead$ahead_arrow"
+ fi
+ fi
+ fi
+ echo $local_commits
+}