λ ryan.himmelwright.net

Clojure Script for Project Git Logs

As mentioned in my last week notes post, I wrote a simple Clojure script to help me review what I’ve completed across projects during a given time period.

As of now, here’s my weekly-commits.clj, which I execute using babashka:

#!/usr/bin/env bb

(require '[babashka.process :refer [shell]])
(require '[babashka.fs :as fs])
(require '[clojure.string :as str])

(def since (if (seq *command-line-args*)
             (str/join " " *command-line-args*)
             "last Monday"))

(def home (System/getProperty "user.home"))

(def projects
  [(str home "/code/home-manager")
   (str home "/code/ryan.himmelwright.net")
   (str home "/code/ParenProjects")
   (str home "/code/PerspectivePixels")])

(defn git-log [git-dir]
  (:out (shell {:dir git-dir :continue true :out :string}
               "git" "--no-pager" "log" (str "--since=" since)
               "--pretty=format:%ad  %s"
               "--date=format:%a %Y-%m-%d %H:%M")))

(defn dirname [dir-path]
  (last (str/split dir-path #"/")))

(defn project-header [dir]
  (str "=== " (dirname dir) " ===\n"))

(defn git-log-string [git-dir]
  (let [git-log (git-log git-dir)]
    (if (str/blank? git-log)
      ;; If blank log
      (str (project-header git-dir) "No commits in time range.\n")
      ;; Else: return normal message
      (str (project-header git-dir) git-log "\n"))))

(doseq [dir projects]
  (if (fs/directory? dir)
    (println (git-log-string dir))
    (println (str (project-header dir) "Project dir (" dir ") not on this computer.\n"))))

In the script, I list out project directories (the projects var) that contain git repos. By default, the script will print out all git log results for each project since last Monday. The logs are printed in a specific format that displays a timestamp to easily see what was completed and when.

Additionally, I added the ability to change the --since flag by providing different values as arguments to the script. For example, bb weekly-commits.clj last Friday would show logs since last Friday (instead of the last Monday default).

For good measure, I added some conditional handling so that if there are no commits, or a project simply isn’t located on a system, it handles the issue gracefully with a message.

For example:

$> bb bin/weekly-commits.clj
=== home-manager ===
Fri 2026-02-13 10:26  Moved PerspectivePixels project to ~/code/
Fri 2026-02-13 09:41  split out ghostty configs, added some elfeed updates
Thu 2026-02-12 17:37  adding immich
Wed 2026-02-11 21:59  Rewrote weekly-commits.clj myself to fix some edge cases
Wed 2026-02-11 21:58  Added zeal to porygon
Wed 2026-02-11 12:21  added weekly-commits script
Wed 2026-02-11 09:27  added vm support

=== ryan.himmelwright.net ===
Sun 2026-02-15 16:04  changed button style
Sat 2026-02-14 15:52  finished editing, publishing
Fri 2026-02-13 15:47  Merge branch 'main' into week-post-1797
Fri 2026-02-13 14:10  added to archive
Fri 2026-02-13 14:10  Updated uses page
Fri 2026-02-13 13:05  Working through edit
Fri 2026-02-13 10:54  Started rough draft to links
Tue 2026-02-10 15:07  Template for week post

=== ParenProjects ===
Thu 2026-02-12 12:27  fixed client issues
Thu 2026-02-12 12:21  added sync support for cli
Thu 2026-02-12 12:02  Added skew automated testing
Thu 2026-02-12 11:49  Added conflict sync testing, and fixed issue with lists editing
Wed 2026-02-11 11:47  fixed bug so that pull sync doesn't run when sync isn't enabled
Wed 2026-02-11 11:41  Further cleanup, sync notifications
Wed 2026-02-11 10:46  refactor cleanup to consolidate app state
Tue 2026-02-10 11:20  Giant refactor to breakdown the clojure bridge in swift

=== PerspectivePixels ===
No commits in time range.

The script is nothing fancy, and I don’t have much else to say about it. It’s just something I threw together one night, and I thought I’d share it. I love the ability to script simple solutions to little problems like this one.

- Back to Post Index -