-
Notifications
You must be signed in to change notification settings - Fork 0
/
integration-test.sh
executable file
·59 lines (48 loc) · 1.49 KB
/
integration-test.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
# Mostly used this as a crutch during development / for debugging purposes.
#
mydir=$(pwd) # Assumes script is ran from the project directory.
workdir=$(mktemp -d)
echo >&2 working in \"$workdir\"
SRC_GIT=$workdir/src.git
DEST_GIT=$workdir/dest.git
DEST_GIT_LFS_FILES=$workdir/dest.git.lfs
mkdir $SRC_GIT $DEST_GIT $DEST_GIT_LFS_FILES
#
# Setup of git repositories and files for testing.
#
# Create destination git repository.
git -C $DEST_GIT init --bare
# Create source repository and enable git-lfs
git="git -C $SRC_GIT"
$git init
$git lfs install
# Add a binary file to the repository, tracked by git-lfs
dd if=/dev/random of=$SRC_GIT/binaryfile.bin bs=1m count=1
$git lfs track '*.bin'
$git add --all
# Create a single commit
$git commit --message 'commit message'
# Add $DEST_GIT as a remote to the source repository
$git remote add origin $DEST_GIT
# Configure the source repository to use git-lfs-agent-rclone to transfer files
$git config lfs.standalonetransferagent rclone
$git config lfs.concurrenttransfers 1
$git config lfs.customtransfer.rclone.path $mydir/git-lfs-agent-rclone
$git config lfs.customtransfer.rclone.args $DEST_GIT_LFS_FILES
#
# Test uploading.
#
GIT_TRACE=1 $git push
if [ $? -ne 0 ]; then
echo >&2 git push failed
exit 1
fi
# Hack: remove the object tracked by git-lfs in the source repository and have git-lfs detect that with fsck so we can then download it
find $SRC_GIT/.git/lfs/objects -type f -delete
$git lfs fsck
#
# Test downloading
#
GIT_TRACE=1 $git lfs pull