Literate Commits (2016)
petecorey.com
Literate Commits (2016)
1–10 of 16 posts
Re: Literate Commits (2016)
#2This post says:
> I’m not advocating using literary commits in real-world software
But I think variations of the underlying thinking are very important for real-world software, even if it's not the exact same thing. Brain dumped this around the time I was working on sophocles at http://shadowfiend.posthaven.com/using-commit-messages-for-d... , and it's still a core part of how I develop software and how I want the teams around me to as well.
Re: Literate Commits (2016)
#3ensuring that each and every commit serves a singular purpose and adds to the narrative history of the project has done wonders to reduce thrash and the introduction of “stupid mistakes”.
Read in chronological order, these commits should paint a clear picture of how and why this particular code came into existence and how it has changed over the course of its life.
I'm not sure if this is particular to 'literate', to me it sounds more like common sense, but yes: that is how I like commit history.
The example https://github.com/pcorey/delete-occurrences-of-an-element-i..., even though the OP mentions it's a toy, illustrates this pretty well. Without knowing much about the code you can just read the commit messages and even though the style of the text is a bit too fuzzy for my liking at times (i.e. lots of words just to form nice prhases to make points which could be made with shorter and more to-the point sentences) there is a much larger problem (imo): the first line of each commit makes no sense whatsoever wrt what actually changed in the code. This makes it impossible to at first sight (in git user interfaces which use the first line in their commit lists, i.e. the vast majority I think) find out what is happening and what a particular commit does. If that is an articfact of literate commits, then sorry but that is just not very good. Here's an excerpt:
# Getting Real
# Forging Ahead
# Keep it Simple
# Our First Test
# Take What We're Given
# Laying the Groundwork
Suppose you come back to this knowing you changed something in a recent commit and want to look it up. My strategy is then usually to just glance over the history for a few seconds to see if I can immediately find the commit I'm looking for before starting an actual search. Works very, very often. Not so much in this case. Compared to what I'm looking at right now in a repository of a team I work with: converters: Fix nullable double getting converted into NaN
plot: Use assembly reference instead of project reference
plot: Update code style and formatting
network: Add functions for element acces to Python scripting API
The body of the commit message then goes on describing more detail and usually also why the change was made. As such creating the narrative the OP talks about. But with the added benefit that the message header provides pretty good insight into what a commit does, hereby providing some kind of index to the book being written, making it much easier to discover things.Re: Literate Commits (2016)
#4Re: Literate Commits (2016)
#5Re: Literate Commits (2016)
#6Re: Literate Commits (2016)
#7Sort of an interesting idea, and I wholehartedly agree with ensuring that each and every commit serves a singular purpose and adds to the narrative history of the project has done wonders to reduce thrash and the introduction of “stupid mistakes”. Read in chronological order, these commits should paint a clear picture of how and why this particular code came into existence and how it has changed over the course of it…
Re: Literate Commits (2016)
#8- Add line-change/diff-specific commentary. This needs to be within the context of a larger commentary/set of changes, as usually the changes are not independent, and in fact relate to simultaneous constraints which inform your chosen solution.
- Add some structure to a list of commits in a branch. I'd like a hierarchy, in fact. I've thought about trying to emulate this by making sub branches and then merging them into a parent branch, but it seemed like it would be a big pain.
Anyway, I've love to see some software that could help with this!
Re: Literate Commits (2016)
#9Eventually I realized that there's a better way to do this: keep your documentation in the same repo as your code, and construct commits that update the documentation AND the tests AND the code all in the same unit. Now your commit message can be much shorter, but you still guarantee that the documentation is exactly aligned with the code that it talks about.
It also means you can add unit tests that check that code is covered by your documentation! https://simonwillison.net/2018/Jul/28/documentation-unit-tes...
Re: Literate Commits (2016)
#10I went through a phase a few years ago of writing ESSAYS in my commit messages, on the basis that they were the only form of documentation which I trusted to stay 100% synchronized with the code. Eventually I realized that there's a better way to do this: keep your documentation in the same repo as your code, and construct commits that update the documentation AND the tests AND the code all in the same unit. Now your…
A very slick way of enforcing this that I've seen is having actual unit tests in your documentation (and of course a CI tool to enforce that tests pass). This is something that I think is extremely cool about Elixir! It forces you to think about testing, documentation (with ACTUAL examples!!), and the problem you're solving all at once. It's a very neat concept.
https://elixir-lang.org/getting-started/mix-otp/docs-tests-a...