1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#!/usr/bin/env bash
set -e
source test/setup
use Test::More
note "Define project-wide GIT setup for all tests"
# Get git-subrepo project top directory
PROJ_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )
if [ -z "${PROJ_DIR}" ] || [ "${HOME}" != "${PROJ_DIR}" ]; then
is "${HOME}" "${PROJ_DIR}" \
"To define project-wide GIT setup for all tests: HOME '${HOME}' should equal PROJ_DIR '${PROJ_DIR}'"
else
# Real GIT configuration for tests is set here:
rm -f "${PROJ_DIR}/.gitconfig"
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git config --global init.defaultBranch "master"
git config --global --add safe.directory "${PROJ_DIR}"
git config --global --add safe.directory "${PROJ_DIR}/.git"
git config --global pull.ff only
git config --global merge.ff only
git config --list
test-exists "${PROJ_DIR}/.gitconfig"
# Running tests depends on the whole project being git initialized.
# So, git initialize the project, if necessary.
if [ ! -d "${PROJ_DIR}/.git" ]; then
cd "${PROJ_DIR}"
git init .
git add .
git commit -a -m"Initial commit"
cd -
fi
test-exists "${PROJ_DIR}/.git/"
# Running tests depends on the whole project not being in a GIT detached HEAD state.
if ! git symbolic-ref --short --quiet HEAD &> /dev/null; then
git checkout -b test
fi
ok "$(
git symbolic-ref --short --quiet HEAD &> /dev/null
)" "Whole project is not in a GIT detached HEAD state"
fi
done_testing
teardown
|