summaryrefslogtreecommitdiffstats
path: root/test-branches.sh
diff options
context:
space:
mode:
authorMichael Allen <michael@michaelallen.io>2015-02-12 16:53:08 +0000
committerMichael Allen <michael@michaelallen.io>2015-02-12 16:53:08 +0000
commit43ac2a587f9b0b218875e3f1aa5a68ed4f1f8f19 (patch)
treea7557b5d64beab088a919562a359e72d925c3726 /test-branches.sh
parent8d7c08e7f0d1fd880345cf4c62b0568e509ce13a (diff)
downloadgit-sonar-43ac2a587f9b0b218875e3f1aa5a68ed4f1f8f19.tar.gz
git-sonar-43ac2a587f9b0b218875e3f1aa5a68ed4f1f8f19.zip
find branch names and commits ahead or behind
Diffstat (limited to '')
-rwxr-xr-xtest-branches.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/test-branches.sh b/test-branches.sh
new file mode 100755
index 0000000..ddf442c
--- /dev/null
+++ b/test-branches.sh
@@ -0,0 +1,39 @@
+scriptDir="$(cd "$(dirname "$0")"; pwd)"
+
+source "$scriptDir/git-base.sh"
+
+tmpfile=""
+
+cd_to_tmp() {
+ tmpfile="/tmp/git-prompt-tests-$(time_now)"
+ mkdir -p "$tmpfile"
+ cd "$tmpfile"
+}
+
+rm_tmp() {
+ cd $scriptDir
+ rm -r "$tmpfile"
+}
+
+test_branch_name_in_repo() {
+ cd_to_tmp
+ git init --quiet
+ git checkout -b foo --quiet
+ assertEquals "foo" "$(branch_name)"
+
+ git checkout -b bar --quiet
+ assertEquals "bar" "$(branch_name)"
+
+ git checkout -b baz --quiet
+ assertEquals "baz" "$(branch_name)"
+
+ rm_tmp
+}
+
+test_branch_name_not_in_repo() {
+ cd_to_tmp
+ assertEquals "" "$(branch_name)"
+ rm_tmp
+}
+
+. ./shunit/shunit2