Finding all my recent git commits
At the moment I'm writing up one of my regular development update posts on the Numbas blog. I try to write one every couple of months. The posts act as a changelog for the various projects related to Numbas.
It's been just over seven months since the last one, because of everything, so this time there's a lot to talk about.
The way I normally do this is to go to GitHub and scroll through the commit log for the Numbas runtime and editor repositories, adding a bullet point for each bug fix or new feature, linking to either the relevant commit, an entry in the issue tracker, or a documentation page.
GitHub has a way of showing you just the commits in a certain range, but it's hard to find. I can't remember how I found it originally - maybe it's linked when you're setting up a pull request or trying to merge a branch into the main one - but I always have to look it up again when I start writing one of these posts.
The URL format is github.com/org/repo/compare/RANGE
.
You'd think that RANGE
is the same syntax that the git command-line tool uses for specifying ranges, but it's subtly differnt.
The string a..b
represents the range between references a
and b
in the git command-line.
GitHub understands this, but shows you file diffs between those two points instead of a list of commits.
You can get it to show you a list of commits by using three dots: a...b
.
I thought this was a weirdly obscure syntax!
I asked on mathstodon if anyone could explain this . @gjm@mathstodon.xyz replied saying that git does use two dots and three dots to mean different things, but not the same things as GitHub:
git log A..B
means "show me commits that are in B but not in A".git log A...B
means "show me commits that are in one of A,B but not both". (So it shows you all the commits on a minimal path joining A and B.)
git diff A..B
means "show me the differences between A and B".git diff A...B
means "show me the differences between (last common ancestor of A,B) and B".
So that's annoying!
Anyway, this is what I've been doing for a few years. Since development on the Numbas LTI tool picked up, I had a third repository to check. And there are separate repositories for each of the extensions to Numbas, and I haven't been in the habit of tagging release numbers for those so I have to just look at the whole commit history.
Today I decided my life would be a lot easier if I could get a list of all the commits in any repository belonging to the numbas organisation since the date of the last blog post.
I asked on mathstodon if this is possible. Mike Sheldon replied with this URL:
https://github.com/search?q=org%3AYOUR_ORG&type=commits&s=committer-date&o=desc
This shows the latest commits in any repository belonging to YOUR_ORG
, most recent first.
There are only 8 commits per page, which isn't many.
I can't work out how to get to this query without just pasting the URL into my browser: just putting org:numbas
in the search box redirects to the organisation's homepage, skipping the search page.
I spent a few minutes putting together a script to fetch these search results in JSON format so I could see all of them in a single table, and then @guetto@mathstodon.xyz suggested writing a script to do it with the git command-line tool.
This makes a lot of sense!
I have all the git repositories, under a numbas
directory, so I just need to write a script that runs git log
in each directory and then collate the commits.
Here's a Jupyter notebook that does that.
It produces a table like this:
numbas/editor | fa79a8c6 | update JME function hints | 2023-06-22 10:29:23+01:00 |
numbas/editor | c2ad9034 | def.ignore is an observable! | 2023-06-22 13:10:43+01:00 |
numbas/Numbas | 8bc07c87 | move loadVariables from SCORMStorage to BlankStorage | 2023-07-04 10:24:03+01:00 |
numbas/editor | 62532897 | in the extension part type's Testing tab, render the prompt | 2023-07-04 15:29:03+01:00 |
numbas/editor | 96aca8be | docs: add an anchor above the pipe operator's documentation | 2023-07-05 08:52:58+01:00 |
numbas/editor | 05c1f98f | capitalise GitHub | 2023-07-05 09:19:42+01:00 |
numbas/editor | be0de545 | version 7.1 | 2023-07-05 09:20:00+01:00 |
numbas/editor | 3a8697f3 | fix a typo | 2023-07-05 09:22:36+01:00 |
That's exactly what I need!
I hope it's useful to somebody else, too.
Update 2023-11-10
Well, I wanted to do a Numbas development update again, and was sure I'd written a script to find recent commits, but couldn't find it. So I wrote the script again, as a command-line tool this time.
And then I found this post.
And then I smacked my head.
So I might as well share the command-line script.