Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
env.list
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ocamlsf/learn-ocaml:0.12
FROM ocamlsf/learn-ocaml:0.13.1

USER root
RUN apk add coreutils dumb-init py3-pip zip unzip \
Expand Down
25 changes: 16 additions & 9 deletions program.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,31 @@ download_repository() {
fi
}

find_repositories() {
find "$1" -name .git -exec dirname {} \;
}

optimize_sync() {
echo "optimizing using git gc"
cd "$SYNC" || error "optimizing_sync: cd $SYNC" || return
DIRS=$(find . -mindepth 4 -maxdepth 4 -type d -not -path "\./\.git*")
for i in $DIRS
for repo in $(find_repositories $SYNC)
do
echo "$i"
cd "$i" || error "optimizing_sync: cd $i" || continue
echo "optimizing $repo"
cd "$repo" || error "optimizing_sync: cd $repo" || continue
git gc
cd - || error "optimizing_sync: cd - (assert false)" || continue
done
git gc
cd ..
echo "optimizing done"
}

clone_sync() {
rm -rf ${BACKUP:?}/$SYNC
echo "cloning sync to avoid concurrency when writing"
find $SYNC -name .git | while read -r repository; do
git clone "$repository" $BACKUP/"$repository"
for repo in $(find_repositories $SYNC)
do
git clone \
--config user.name="Learn-OCaml user" \
--config user.email="[email protected]" \
"$repo" $BACKUP/"$repo"
done
# copy directories which are not repositories yet
echo "cp -rn $SYNC $BACKUP/$SYNC"
Expand Down Expand Up @@ -76,6 +80,9 @@ watch_upload() {
sleep $BEGIN &
PIDSLEEP=$!
wait $PIDSLEEP
# In case the first sleep is killed
date
upload_repository "$1"
while ! [ -f $STOP ]
do
sleep $INTERVAL &
Expand Down