You've finished work for the day, and you'd like a list of URLs to send your boss of your commits.
Use gitYesterday! Using node.js spawn and moment.js, we create permalink URLs to our commits on Github.
GH stores commits as URL/sha_commit_id
Get the start of yesterday using moment().subtract(1, "days").startOf("day").toString();
Spawn a child process (like Alien) using spawn:
const gitLog = spawn("git", [
"log",
`--after=${START_OF_DAY}`,
`--before=${END_OF_DAY}`,
`--author=${AUTHOR}`,
]);
When the child expulses up some data, we can log it:
gitLog.stdout.on("data", (data) => {
const commits = data.toString().split("\n\n\n");
commits.forEach((commit) => {
...
const hash = commitLine.split(" ")[1];
const url = createGHURL(hash);
...
});
});
Finally, we capture any exit codes, so we don't have to kill -9 anything we don't want to (again, like Alien).
var cleanExit = function () {
process.exit();
};
process.on("SIGINT", cleanExit); // catch ctrl-c
process.on("SIGTERM", cleanExit); // catch kill
Note! this must be run in the repo that has the .git folder
Ohhhhh yeah, that's nice. Unlike Alien.
Commits from **Sun Jul 24 2022 00:00:00 GMT-0500** to **Sun Jul 24 2022 23:59:59 GMT-0500** for **Bram Adams** from [**bramses/gitLastDay**](https://github.com/bramses/gitLastDay/)
Running: git log --after=Sun Jul 24 2022 00:00:00 GMT-0500 --before=Sun Jul 24 2022 23:59:59 GMT-0500 --author=Bram Adams
[this is an example](https://github.com/bramses/gitLastDay/commit/caf9d4dfc0fb3ea29f73e80a991a5defd43cc3af)
nb: do not go to that SHA!
Turn the executable into an Alfred script!
Never do the same work more than once
Watchin haters hate cause Brambino got the game locked
25% of the way to becoming the Avatar
Each week, I send out something that looks like this. Sign up below if you want in!