From f0027a41cef2915fd9c0db4129c7b3ab2c6cfb56 Mon Sep 17 00:00:00 2001 From: mollusk Date: Wed, 29 May 2019 09:16:26 -0700 Subject: [PATCH] New Script: trimrepo.sh: trim blobs from history Former-commit-id: 4cbb392769c51f1cad72a49f39e162bdf1eeeea5 [formerly 7399811e55482ed592db0afb02558105232c95fb] [formerly e136ec62efe655d1d11a933d4a7dc7d5a0be7676] Former-commit-id: ea9ffb1557cc19fddee168974f9e10f788164f95 Former-commit-id: d780d1815ada5f008abce6712d8f21bb81df9532 --- trimrepo.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 trimrepo.sh diff --git a/trimrepo.sh b/trimrepo.sh new file mode 100755 index 0000000..ca10eeb --- /dev/null +++ b/trimrepo.sh @@ -0,0 +1,46 @@ +#!/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 +