Skip to content

Commit 11af447

Browse files
committed
Setting default GIT configuration as test/ being HOME during tests
1 parent e4f529e commit 11af447

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/git-subrepo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ assert-repo-is-ready() {
15341534
[[ $command =~ ^(help|version|upgrade)$ ]] && return
15351535

15361536
# We must be inside a git repo:
1537-
git rev-parse --git-dir &> /dev/null ||
1537+
git rev-parse --is-inside-git-dir &> /dev/null ||
15381538
error "Not inside a git repository."
15391539

15401540
# Get the original branch and commit:

test/setup

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ fi
2323
export XDG_CONFIG_HOME=$SCRIPT_DIR
2424
export HOME=$SCRIPT_DIR
2525
export GIT_CONFIG_NOSYSTEM=1
26+
# Set global GIT configuration for tests:
27+
if [ ! -f "${HOME}/.gitconfig" ]; then
28+
git config --global user.email "you@example.com"
29+
git config --global user.name "Your Name"
30+
git config --global init.defaultBranch "master"
31+
git config --global --add safe.directory "$(pwd)"
32+
git config --global --add safe.directory "$(pwd)/.git"
33+
if ! git symbolic-ref --short --quiet HEAD; then
34+
git checkout -b test
35+
fi
36+
fi
2637
# To be able to view current GIT confirguration during tests execution,
2738
# run the test suite by adding the '-v' option to the prove command.
2839
git config --list

0 commit comments

Comments
 (0)