jitty-scripts/trimrepo.sh
mollusk 4cbb392769 New Script: trimrepo.sh: trim blobs from history
Former-commit-id: e136ec62efe655d1d11a933d4a7dc7d5a0be7676
Former-commit-id: 7399811e55482ed592db0afb02558105232c95fb
2019-05-29 09:16:26 -07:00

47 lines
998 B
Bash
Executable File

#!/bin/bash
chk_deps()
{
if [ ! -f /usr/bin/tux ] || [ ! -f /usr/bin/sudo ];then
echo "Please install: tuxc & sudo, one of them was not found"
exit 1
sudo tux i openjdk-8-jre wget
fi
}
dl_bins()
{
file_name="bfg"
file_version="1.13.0"
dldest="./"
dltool="wget"
dlurl="https://repo1.maven.org/maven2/com/madgag/bfg/${file_version}/${file_name}-${file_version}.jar"
if [ -f ./bfg-1.13.0.jar ];then
echo "${file_name}-${file_version} already exists"
return
elif [ ${dltool} = "wget" ];then
${dltool} ${dlurl} -P ${dldest}
elif [ ${dltool} = "aria2c" ];then
${dltool} -x 10 -j 10 ${dlurl} -d ${dldest}
fi
}
chk_deps
dl_bins
trim_size="10M"
if [ ! -d .git/ ];then
echo "This is not a git repository"
else
java -jar ./${file_name}-${file_version}.jar --strip-blobs-bigger-than ${trim_size}
git reflog expire --expire=now --all && git gc --prune=now --aggressive
fi