]> git.scottworley.com Git - pinch/blame - tests/lib/test-setup.sh
Set git user in test harness
[pinch] / tests / lib / test-setup.sh
CommitLineData
a2290fb1
SW
1set -e
2
1b48018c
SW
3export GIT_AUTHOR_NAME=automation
4export GIT_COMMITTER_NAME=automation
5export GIT_AUTHOR_EMAIL=auto@mati.on
6export GIT_COMMITTER_EMAIL=auto@mati.on
7
78c89e6e
SW
8cache_dir=$(mktemp -d)
9export XDG_CACHE_HOME=$cache_dir
10
a2290fb1
SW
11foo_setup() {
12
13 repo_dir="`mktemp -d`"
14 repo="$repo_dir/repo"
15 git init "$repo"
16 (
17 cd "$repo"
18 echo Contents > test-file
19 git add test-file
20 git commit -m 'Commit message'
21 )
22
23 conf="`mktemp`"
24 cat > "$conf" <<EOF
25[foo]
26git_repo = file://$repo
27git_ref = master
28EOF
29
30}
31
d9a1088a
SW
32test_cleanup() {
33 if [ "$repo_dir" ];then rm -rf "$repo_dir"; fi
34 if [ "$conf" ];then rm "$conf"; fi
78c89e6e 35 if [ "$cache_dir" ];then rm -rf "$cache_dir"; fi
a2290fb1 36}
d9a1088a
SW
37
38trap test_cleanup EXIT INT TERM