Skip to content
Merged
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
14 changes: 2 additions & 12 deletions python-clients/cs50vsix-client/clean50/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import termcolor
import time

BFG_VERSION = "1.14.0"
BFG = f"bfg-{BFG_VERSION}.jar"
INSTALL_DIR = "/opt/share"
BFG = "/opt/share/bfg.jar"

def main():
args = parse_args(sys.argv[1:])
Expand All @@ -31,20 +29,12 @@ def main():
sys.exit(red("Operation aborted."))

try:

# Check to see if BFG repo cleaner is already installed
if not os.path.isfile(f"{INSTALL_DIR}/{BFG}"):
print(yellow(f"BFG not found, downloading BFG to {INSTALL_DIR} ..."))
subprocess.run(f"wget https://repo1.maven.org/maven2/com/madgag/bfg/{BFG_VERSION}/{BFG} -P {INSTALL_DIR}/",
check=True, shell=True, stdout=stdout, stderr=stderr
)

print(yellow("Cleaning up unnecessary files and optimizing local repository..."))
subprocess.run("git gc", check=True, shell=True, stdout=stdout, stderr=stderr)

print(yellow("Running BFG repo cleaner to remove large files from commit history..."))
commands = ";".join([
f"java -jar {INSTALL_DIR}/{BFG} --no-blob-protection --strip-blobs-bigger-than 100M",
f"java -jar {BFG} --no-blob-protection --strip-blobs-bigger-than 100M",
"git reflog expire --expire=now --all",
"git gc --prune=now --aggressive"
])
Expand Down