File tree Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ compgen: force
110110 $(SHARE ) /zsh-completion/_git-subrepo
111111
112112clean :
113- rm -fr tmp test/tmp test/repo
113+ rm -fr tmp test/tmp test/repo .gitconfig
114114
115115define docker-make-test
116116 docker run --rm \
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 " you@example.com"
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 @@ -15,9 +15,15 @@ if [ ! -d "${SCRIPT_DIR}/../.git" ]; then
1515 git config user.name " YouUser"
1616 git add .
1717 git commit -a -m" Initial commit"
18- git config --list
1918fi
2019
20+ # Disable any GIT configuration set outside this 'git-subrepo' project.
21+ # Real GIT configuration for tests is set through the first test
22+ # (00-git-config.t).
23+ export XDG_CONFIG_HOME=$PWD
24+ export HOME=$PWD
25+ export GIT_CONFIG_NOSYSTEM=1
26+
2127# Generate additional testing git repos, if not already present.
2228mkdir -p " ${SCRIPT_DIR} /repo"
2329if [ ! -d " ${SCRIPT_DIR} /repo/bar" ]; then
You can’t perform that action at this time.
0 commit comments