-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-experiment
executable file
·43 lines (36 loc) · 1.38 KB
/
run-experiment
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
set -eu
gitoxide_repo='../gitoxide' # For the `arrow` example filter.
# Read command-line arguments.
gitlike_cmd="${1:?pass the command to test (git or gix) as an argument}"
shift
# Stop if repositories are left over from a previous run.
if test -e remote-repo || test -e local-clone; then
printf 'Found repos from previous experiment, stopping.\n' >&2
exit 2
fi
# Build the arrow example and symlink to it, if necessary.
(cd -- "$gitoxide_repo" && cargo build -p gix-filter --example arrow)
test -e arrow || ln -s -- "$gitoxide_repo/target/debug/examples/arrow"
# Report the experiment.
printf 'Testing: %s\n' "$gitlike_cmd $*"
set -x
# Compose the command that will run the arrow example using an absolute path.
# (git and gix treat relative paths as relative to different locations, here.)
sq="'"
bs="\\"
filter_path="$(realpath arrow)"
filter_cmd="'$(printf '%s\n' "$filter_path" | sed "s/$sq/$sq$bs$bs$sq$sq/g")' process"
# Create the remote repository.
git init -q remote-repo
echo '[ab] filter=arrow-example' >remote-repo/.gitattributes
echo A >remote-repo/a
echo B >remote-repo/b
echo C >remote-repo/c
chmod +x remote-repo/[bc]
git -C remote-repo add .
git -C remote-repo commit -m 'Initial commit'
# Clone it and show the clone.
"$gitlike_cmd" "$@" -c filter.arrow-example.process="$filter_cmd" \
clone "file://$(realpath remote-repo)" local-clone
ls --color -AlF local-clone