File tree 3 files changed +63
-2
lines changed
3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ compgen: force
110
110
$(SHARE ) /zsh-completion/_git-subrepo
111
111
112
112
clean :
113
- rm -fr tmp test/tmp test/repo
113
+ rm -fr tmp test/tmp test/repo .gitconfig
114
114
115
115
define docker-make-test
116
116
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
" [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 @@ -15,9 +15,15 @@ if [ ! -d "${SCRIPT_DIR}/../.git" ]; then
15
15
git config user.name " YouUser"
16
16
git add .
17
17
git commit -a -m" Initial commit"
18
- git config --list
19
18
fi
20
19
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
+
21
27
# Generate additional testing git repos, if not already present.
22
28
mkdir -p " ${SCRIPT_DIR} /repo"
23
29
if [ ! -d " ${SCRIPT_DIR} /repo/bar" ]; then
You can’t perform that action at this time.
0 commit comments