File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -e
4+
5+ source test/setup
6+
7+ use Test::More
8+
9+ note " Define project-wide GIT setup for all tests"
10+
11+ # Get git-subrepo project top directory
12+ PROJ_DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd )
13+
14+ if [ -z " ${PROJ_DIR} " ] || [ " ${HOME} " != " ${PROJ_DIR} " ]; then
15+ is " ${HOME} " " ${PROJ_DIR} " \
16+ " To define project-wide GIT setup for all tests: HOME '${HOME} ' should equal PROJ_DIR '${PROJ_DIR} '"
17+ else
18+
19+ # Real GIT configuration for tests is set here:
20+ rm -f " ${PROJ_DIR} /.gitconfig"
21+ git config --global user.email
" [email protected] " 22+ git config --global user.name " Your Name"
23+ git config --global init.defaultBranch " master"
24+ git config --global --add safe.directory " ${PROJ_DIR} "
25+ git config --global --add safe.directory " ${PROJ_DIR} /.git"
26+ git config --list
27+
28+ test-exists " ${PROJ_DIR} /.gitconfig"
29+
30+ # Running tests depends on the whole project being git initialized.
31+ # So, git initialize the project, if necessary.
32+ if [ ! -d " ${PROJ_DIR} /.git" ]; then
33+ cd " ${PROJ_DIR} "
34+ git init .
35+ git add .
36+ git commit -a -m" Initial commit"
37+ cd -
38+ fi
39+
40+ test-exists " ${PROJ_DIR} /.git/"
41+
42+ # Running tests depends on the whole project not being in a GIT detached HEAD state.
43+ if ! git symbolic-ref --short --quiet HEAD & > /dev/null; then
44+ git checkout -b test
45+ fi
46+
47+ ok " $(
48+ git symbolic-ref --short --quiet HEAD & > /dev/null
49+ ) " " Whole project is not in a GIT detached HEAD state"
50+
51+ fi
52+
53+ done_testing
54+
55+ teardown
Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ source "$PWD"/.rc
1111# Get the location of this script
1212SCRIPT_DIR=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd )
1313
14+ # Disable any GIT configuration set outside this 'git-subrepo' project.
15+ # Real GIT configuration for tests is set through the first test
16+ # (00-git-config.t).
17+ export XDG_CONFIG_HOME=$PWD
18+ export HOME=$PWD
19+ export GIT_CONFIG_NOSYSTEM=1
20+
1421BASHLIB=$(
1522 find " $PWD " / -type d -name bin -o -type d -name lib | tr ' \n' ' :'
1623)
You can’t perform that action at this time.
0 commit comments