Skip to content

Instantly share code, notes, and snippets.

@yzdbg
Last active November 3, 2023 17:11
Show Gist options
  • Star 79 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save yzdbg/bee9031fcaa918abf6442c2691866dda to your computer and use it in GitHub Desktop.
Save yzdbg/bee9031fcaa918abf6442c2691866dda to your computer and use it in GitHub Desktop.

Automating Daily Reports, because fuck it, really...

Each day at our company, developers are required to document their activities, painstakingly jotting down their daily work and future plans. A monotonous chore that I just really dislike.

So now, there's a scribe for that :

auto-dr-

Code

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 user.name").toString().trim();

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

// Display the current day
console.log(`*${currentDay}*`);

// Get the list of branches
const branches = execSync('git branch --format="%(refname:short)" --no-column')
  .toString()
  .trim()
  .split("\n");

// 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}`
  )
    .toString()
    .trim();

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

// Display tomorrow's day
console.log(`*${nextDay}*`);
console.log("-");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment