Skip to main content

git: remove a now-unused script to find big commits

ID
6fde0a4
date
2026-01-05 20:09:29+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
1a796a6
message
git: remove a now-unused script to find big commits
changed files
2 files, 1 addition, 90 deletions

Changed files

git/README.md (7050) → git/README.md (6631)

diff --git a/git/README.md b/git/README.md
index ba1c1d3..0dfbfce 100644
--- a/git/README.md
+++ b/git/README.md
@@ -32,12 +32,6 @@ scripts = [
         """
     },
     {
-        "name": "find_big_commits.py",
-        "description": """
-        print some information about the biggest files/commits in the Git history.
-        """
-    },
-    {
         "usage": "gb [name]",
         "description": """
         alias for <a href="https://git-scm.com/docs/git-checkout"><code>git checkout -b [name]</code></a>, which creates a new branch
@@ -137,15 +131,6 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
   </dd>
 
   <dt>
-    <a href="https://github.com/alexwlchan/scripts/blob/main/git/find_big_commits.py">
-      <code>find_big_commits.py</code>
-    </a>
-  </dt>
-  <dd>
-    print some information about the biggest files/commits in the Git history.
-  </dd>
-
-  <dt>
     <a href="https://github.com/alexwlchan/scripts/blob/main/git/gb">
       <code>gb [name]</code>
     </a>
@@ -249,4 +234,4 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
     open the current Git repo in <a href="https://gitup.co/">GitUp</a>, my GUI Git client of choice
   </dd>
 </dl>
-<!-- [[[end]]] (sum: kgos+cwNSe) -->
+<!-- [[[end]]] (sum: vSOg0LYPZG) -->

git/find_big_commits.py (2033) → git/find_big_commits.py (0)

diff --git a/git/find_big_commits.py b/git/find_big_commits.py
deleted file mode 100755
index 6a50454..0000000
--- a/git/find_big_commits.py
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/usr/bin/env python3
-"""
-Give some information about the biggest files in the .git folder.
-
-This is based on a Stack Overflow answer by raphinesse [1], with a bunch of
-extra formatting and the total of the .git folder printed also.
-
-[1]: https://stackoverflow.com/a/42544963/1558022
-
-"""
-
-import os
-import subprocess
-
-import humanize
-import termcolor
-
-
-def get_blobs():
-    output = subprocess.check_output(
-        "git rev-list --objects --all | "
-        "git cat-file --batch-check='%(objecttype)\t%(objectname)\t%(objectsize)\t%(rest)'",
-        shell=True,
-    )
-
-    for line in output.decode("utf8").splitlines():
-        object_type, object_name, object_size, rest = line.split("\t")
-
-        if object_type == "blob":
-            yield {"commit_id": object_name, "size": int(object_size), "filename": rest}
-
-
-def get_file_paths_under(root=".", *, suffix=""):
-    """Generates the paths to every file under ``root``."""
-    if not os.path.isdir(root):
-        raise ValueError(f"Cannot find files under non-existent directory: {root!r}")
-
-    for dirpath, _, filenames in os.walk(root):
-        for f in filenames:
-            if os.path.isfile(os.path.join(dirpath, f)) and f.lower().endswith(suffix):
-                yield os.path.join(dirpath, f)
-
-
-def get_git_folder_size():
-    root = (
-        subprocess.check_output(["git", "rev-parse", "--show-toplevel"])
-        .decode("utf8")
-        .strip()
-    )
-
-    return sum(
-        os.path.getsize(p) for p in get_file_paths_under(os.path.join(root, ".git"))
-    )
-
-
-if __name__ == "__main__":
-    blobs = [b for b in get_blobs() if b["size"] >= 1024]
-
-    for b in sorted(blobs, key=lambda b: b["size"]):
-        print(
-            b["commit_id"][:7],
-            humanize.naturalsize(b["size"]).rjust(10),
-            "  ",
-            b["filename"],
-        )
-
-    print(
-        " " * 7,
-        termcolor.colored(
-            humanize.naturalsize(get_git_folder_size()).rjust(10), "blue"
-        ),
-        "  ",
-        termcolor.colored(".git", "blue"),
-    )