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 :
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("-");