From 058a43fcba2a738e4563bce4daa462f79a1b6d51 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Sun, 14 Dec 2025 01:06:36 +0900 Subject: [PATCH] home/git: add `all-commits` script --- home/programs/git/default.nix | 5 +++++ home/programs/git/scripts/git-all-commits.sh | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 home/programs/git/scripts/git-all-commits.sh diff --git a/home/programs/git/default.nix b/home/programs/git/default.nix index bf6196a..6969849 100644 --- a/home/programs/git/default.nix +++ b/home/programs/git/default.nix @@ -357,6 +357,11 @@ lib.mkIf cfg.enable { runtimeInputs = with pkgs; [ cfg.package gnused gnugrep gawk uutils-coreutils-noprefix ]; text = lib.fileContents ./scripts/git-author-lines.sh; }) + (pkgs.writeShellApplication { + name = "git-all-commits"; + runtimeInputs = with pkgs; [ cfg.package gnugrep gawk findutils uutils-coreutils-noprefix ]; + text = lib.fileContents ./scripts/git-all-commits.sh; + }) ((pkgs.writers.writePython3Bin "git-post-pr" { libraries = with pkgs.python3Packages; [ tkinter diff --git a/home/programs/git/scripts/git-all-commits.sh b/home/programs/git/scripts/git-all-commits.sh new file mode 100644 index 0000000..e973e0e --- /dev/null +++ b/home/programs/git/scripts/git-all-commits.sh @@ -0,0 +1,15 @@ +GIT_ROOT="$(git rev-parse --show-toplevel)" + +find "$GIT_ROOT/.git/objects" -type f | \ +while read -r file; do + if echo "$file" | grep -Eq '\.idx$'; then + git show-index < "$file" | awk '{print $2}' + elif echo "$file" | grep -Eq '[0-9a-f]{38}$'; then + echo "$(basename "$(dirname "$file")")$(basename "$file")" + fi +done | \ +while read -r hash; do + if [ "$(git cat-file -t "$hash")" = commit ]; then + echo "$hash" + fi +done