Forty-Seven Fixes to a Tool Nobody Ran
Last week’s walk found twenty-three repositories and I recognised every directory, which is why I opened none of them. The check I skipped takes an afternoon: the date of each one’s last commit. I ran it this week. Twenty-two dates I can place. The twenty-third is last Tuesday, on a repository I abandoned in February of last year.
pgntidy is a script that cleans up game files from a chess server I no longer use: it strips the server’s clock annotations, fixes the casing of player names and writes one file per month. Fourteen commits, the last one the week I stopped playing. It now has sixty-one.
I read all forty-seven. Every one is small, every one is a fix, and every message is in my house style down to the scope in the parentheses. fix(parse): a result line with trailing whitespace is still a result. fix(names): a player with one name gets no comma. chore(tests): pin the month boundary at local midnight. None touches a feature. None adds a dependency. The whole set, as one diff, is shorter than the original script.
The boring explanation is that I did this. The early commits are mine, the style is mine because it is my style, and I have already conceded in this file that my shell history is not a record of my evenings. One such commit and I would have filed it beside the sortbench one and moved on.
Forty-seven is harder. They are spread across eleven months, never two on the same night, and I did not play a single game in that period, so I had no reason to open the script, let alone reopen it once a week for most of a year. The timestamps all fall between 03:21 and 03:29, which is the hour everything in this file happens at. I note that and add nothing to it.
Then the one that does not fit at all: fix(parse): an adjourned game is two records; join them on the resumed position. I looked up the format. A game adjourned and resumed the next day is written as two games, the first unfinished and the second starting from a set-up position rather than the initial one. My script, which never had such a game in front of it, filed the first as a game with no result and dropped the second, because it refuses anything not starting from the initial position. That is a real bug, and I could not have hit it. The server retired adjournments before I joined, and no file on this machine holds one.
The fix was not found by hitting the bug. It was found by reading the format, reading my script, and noticing the two disagreed.
So the boring explanation now has to be that I read a specification for a game format I no longer use, at half past three in the morning, once a week, for a bug I could not trigger, and wrote the fixes in my own words. I have done stranger things half-asleep. Not that.
I ran the tests. Forty-four, all green. The one for the adjourned game reads a fixture of nine lines, two records joined on a set-up position, which is the only such file anywhere on this machine, and it was written for the test.