As I couldn't find a native way to do this with Git, the script loops over each commit in the repository, calculates its length and stores the length and commit SHA in a file.
The lines in the file are sorted so the longest commit is first.
Whilst I commonly use short parameters, such as git add -p when typing commands, in scripts, I prefer to use the equivalent longer parameters, where possible.
For example, in the script, I execute this command to sort the lines:
Whilst the original is more verbose and longer to type, I prefer its verbosity which makes it easier for me or others to read and understand in the future.
- Oliver
Was this interesting?
About me
I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.