The following is a script I run for generating a daily report based on my commit messages. As a bonus, this technique passively encourages better commit habits because you yourself use each commit later, and thus if you write it once correctly and succinctly, you can be lazy and reuse it.

The script is pretty simple. It determines the current day’s time frame and then deduces the next day from that frame. Then it gets all the git branches in the current repository and sees if they have commits from the current day on them. If the branch does contain commits from the current day, then it produces a summary of those commits by the current user and pretty prints the commit message.

const { execSync } = require("child_process");

// Get the current day and tomorrow's day
const currentDay = new Date().toLocaleDateString("en-US", { weekday: "long" });
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
const nextDay = tomorrow.toLocaleDateString("en-US", { weekday: "long" });

// Get the current user from Git configuration
const currentUser = execSync("git config").toString().trim();

// Set the start of the day
const startOfDay = `${currentDay}T00:00:00`;

// Display the current day

// Get the list of branches
const branches = execSync('git branch --format="%(refname:short)" --no-column')

// Iterate through each branch
branches.forEach((branch) => {
  // Get the commits made by the current user since the start of the day on the specific branch
  const commits = execSync(
    `git log --author="${currentUser}" --since="${startOfDay}" --pretty=format:'- %s' ${branch}`

  // If there are commits, display them under the branch header
  if (commits) {
    console.log(`*Branch: ${branch}*`);

// Display tomorrow's day

This should be run with node daily.js in the target repo.

Git commands

This script uses three commands and could easily be replicated in other languages.

git config to figure out the current user’s name. git branch --format="%(refname:short)" --no-column to list out all branches git log --author="${currentUser}" --since="${startOfDay}" --pretty=format:'- %s' ${branch} to list all the commits for the branch that match the current day.

Next time

Next time, I’ll write this in Go to make it a CLI tool.