A collection of computer, gaming and general nerdy things.

Monday, September 15, 2014

Forgetting to Commit

So, I've made a grave mistake.

I forgot to commit. I wrote a bunch of code for FlaskAmp. Like a bunch. And didn't commit anything along the way. Whoops.

There's two ways I can see to correct this:

  1. Create a monster commit.
  2. Reconstruct each part of the code along the way.

Both of these are painful in their own right.

Monster Commit

There's nothing inherently wrong with a big commit. Sometimes when you make a change, you need to cascade changes through a code base. For example, changing the way a model is structured changes the way it's queried and the way it's serialized. There's nothing wrong with adding several files to a commit -- in fact, if you're not committing changes like this, you're probably doing it wrong.

Where there's a problem is what I did. Added many features, made many changes and didn't commit any of them. Whoops... Now, I'm faced with adding nine files that add:

  • Several new models.
  • Modifies all existing models.
  • Modifies existing queries.
  • Redefines all the serializers/Schemas.
  • Redefines how serializers/schemas are created.
  • Defines new marshmallow fields for the Serializers/Schema.
  • Adds a few new libraries.
  • Changes the information relayed in the API (including adding, changing and removing fields)
  • Changes internals of how information is added to the database.
  • Changes internal naming conventions.

Pretty much the local code for FlaskAmp looks completely different from the code in version control. I could just commit it all and be done. Vow to never let it happen again. Et cetera. But when something breaks in it...I can't go back and precisely locate the change I did that broke it because pretty much everything changed.

Reconstruct the Commits

This is likely the option I'll take. But it's going to be painful. It's going to involve rewriting a bunch of code -- hopefully better this time. I'll stash everything current in a development branch. Revert Master (also, I'm developing on FlaskAmp/Master...) to the state recorded on Github and begin making changes slowly. Annotating each commit thoughtfully (I recently read a suggestion to annotate with a line from the Zen of Python if appropriate).

If I go down this route, I'll suffer immediate repercussions for what I did instead of maybe, eventually down the road repercussions. It'll also allow me to write incremental tests as well. Did I mention I haven't been doing that as well? :(

For shame Alec. For shame.

No comments:

Post a Comment