Skip to content

Commit

Permalink
Show typechange as a modification (deviates from posh-git).
Browse files Browse the repository at this point in the history
This deviates from posh-git.

Update the test framework with an option to explicitly use the fixtures in the
scratch directory from a previous test run.

Resolves #46.
  • Loading branch information
lyze committed Jun 23, 2020
1 parent 67a5159 commit 0a236e8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
48 changes: 45 additions & 3 deletions git-prompt-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,37 @@

set -e

OPTS=$(getopt --options= --longoptions=use-existing-fixtures -n "$0" -- "$@")
if [ $? -ne 0 ]; then
exit 1
fi
eval set -- "$OPTS"
unset OPTS
while true; do
case "$1" in
--use-existing-fixtures)
readonly USE_EXISTING_FIXTURES=true
shift
continue
;;
--)
shift
break
;;
esac
done

readonly PS=$(readlink -f tmp/powershell/pwsh)
readonly SRC_DIR=$(readlink -f .)
readonly POSH_GIT_DIR=$(readlink -f tmp/posh-git)
readonly TEST_SCRATCH_DIR=$(readlink -f tmp/test-scratch)

if [ -n "$USE_EXISTING_FIXTURES" ]; then
echo -e "\e[33m[ WARN ] using preexisting test fixtures\e[0m"
else
rm -rf $TEST_SCRATCH_DIR
fi

DIFF_FLAGS=
case "$-i" in
*i*) if [ -z "$TRAVIS" ]; then
Expand Down Expand Up @@ -126,10 +152,15 @@ internal_run_test() {

echo '[ RUN ] '$testcase

mkdir -p $TEST_SCRATCH_DIR/$testcase/git
cd $TEST_SCRATCH_DIR/$testcase/git
mkdir -p $TEST_SCRATCH_DIR/$testcase
cd $TEST_SCRATCH_DIR/$testcase

if [ ! -f ../git_setup_complete ]; then
if [ -f git_setup_complete ]; then
cd git
else
rm -rf git/
mkdir git
cd git
git init &>/dev/null
$git_setup_fn &>/dev/null
touch ../git_setup_complete
Expand Down Expand Up @@ -187,6 +218,17 @@ one_file_staged_with_unstaged_edit() {
}
run_test_known_diff one_file_staged_with_unstaged_edit '[master ? +1 ~0 -0 | +0 ~1 -0]'

one_file_typechange() {
touch file_or_link
touch target
git add .
git commit -m 'first commit'

rm file_or_link
ln -s target file_or_link
}
run_test_known_diff one_file_typechange '[master ? +0 ~1 -0]'

one_file_stashed() {
touch stuff
git add .
Expand Down
8 changes: 7 additions & 1 deletion git-prompt.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bash/zsh git prompt support
#
# Copyright (C) 2018 David Xu
# Copyright (C) 2020 David Xu
#
# Based on the earlier work by Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
Expand Down Expand Up @@ -329,6 +329,9 @@ __posh_git_echo () {
M )
(( indexModified++ ))
;;
T )
(( indexModified++ ))
;;
R )
(( indexModified++ ))
;;
Expand All @@ -352,6 +355,9 @@ __posh_git_echo () {
M )
(( filesModified++ ))
;;
T )
(( filesModified++ ))
;;
D )
(( filesDeleted++ ))
;;
Expand Down

0 comments on commit 0a236e8

Please sign in to comment.