summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-07-23 19:35:09 +0100
committerMichael Allen <michael@michaelallen.io>2015-07-23 19:35:09 +0100
commit5c31b9242140877bef777dd37f0810457bd9b64a (patch)
treeb1f29561e5b0dd7ea8a302fc21c1426c9de61543
parent292a040b4abbbf085b97f7b285e67c97960dc510 (diff)
downloadgit-sonar-5c31b9242140877bef777dd37f0810457bd9b64a.tar.gz
git-sonar-5c31b9242140877bef777dd37f0810457bd9b64a.zip
provide the ability to surround letter in a status with a color
-rwxr-xr-xgit-base.sh4
-rwxr-xr-xtest-files.sh2
-rwxr-xr-xtest-status.sh31
3 files changed, 34 insertions, 3 deletions
diff --git a/git-base.sh b/git-base.sh
index 2385592..9152caf 100755
--- a/git-base.sh
+++ b/git-base.sh
@@ -277,7 +277,7 @@ unstaged_status() {
local suffix=${3:-""}
local unstaged_string=""
- local filesModified="$(echo "$gitStatus" | grep -p "[AMCDR ]M " | wc -l | grep -oEi '[1-9][0-9]*')"
+ local filesModified="$(echo "$gitStatus" | grep -p "[ACDR ]M " | wc -l | grep -oEi '[1-9][0-9]*')"
local filesDeleted="$(echo "$gitStatus" | grep -p "[AMCR ]D " | wc -l | grep -oEi '[1-9][0-9]*')"
if [ -n "$filesDeleted" ]; then
@@ -298,7 +298,7 @@ untracked_status() {
local filesUntracked="$(echo "$gitStatus" | grep -p "?? " | wc -l | grep -oEi '[1-9][0-9]*')"
if [ -n "$filesUntracked" ]; then
- untracked_string="$untracked_string$filesUntracked$untracked$added"
+ untracked_string="$untracked_string$filesUntracked${prefix}A${suffix}"
fi
echo "$untracked_string"
}
diff --git a/test-files.sh b/test-files.sh
index 2bfa944..97a017e 100755
--- a/test-files.sh
+++ b/test-files.sh
@@ -22,7 +22,7 @@ test_untracked_files() {
assertEquals "" "$(untracked_status)"
touch foo
- assertEquals "1$untracked$added" "$(untracked_status)"
+ assertEquals "1A" "$(untracked_status)"
git add .
assertEquals "" "$(untracked_status)"
diff --git a/test-status.sh b/test-status.sh
index 8b9cf2f..a831151 100755
--- a/test-status.sh
+++ b/test-status.sh
@@ -2,6 +2,37 @@ scriptDir="$(cd "$(dirname "$0")"; pwd)"
source "$scriptDir/git-base.sh"
+test_prefix_and_suffix() {
+ status="""
+ M unstaged-modified
+ D unstaged-deleted
+M staged-modified
+A staged-added
+D staged-deleted
+C staged-copied
+R staged-renamed
+UD deleted-them-conflicted
+AU added-us-conflicted
+UU modified-both-conflicted
+?? untacked
+"""
+
+ prefix="_"
+ suffix="-"
+
+ assertEquals "line:${LINENO}" "1_D-1_M-"\
+ "$(unstaged_status "$status" "$prefix" "$suffix")"
+
+ assertEquals "line:${LINENO}" "1_A-1_D-1_M-1_R-1_C-"\
+ "$(staged_status "$status" "$prefix" "$suffix")"
+
+ assertEquals "line:${LINENO}" "1_U-1_T-1_B-"\
+ "$(conflicted_status "$status" "$prefix" "$suffix")"
+
+ assertEquals "line:${LINENO}" "1_A-"\
+ "$(untracked_status "$status" "$prefix" "$suffix")"
+}
+
test_basic_unstaged_options() {
status="""
M modified-and-unstaged