Affiliate marketing for WordPress, made easy

Over this past weekend at WordCamp Phoenix, I had the pleasure of sitting down with the 3/4 of the Easy Digital Downloads core development team. Pippin, Dan, and Chris traveled from their respective hometowns to attend a WordCamp in my backyard. This was the first time I’d had a chance to meet Dan and Chris in person, although we’ve gone back and forth on many of GitHub issues.

Which brings me to the point of writing this. At one point I believe Chris had stumbled upon a bit of code he wanted to commit, and when asked what ‘issue’ it was related to, we all had a small discussion on commits and how they should always be tied to an issue (or ticket, project, etc). I use the word ‘issue’ as that’s the way GitHub tracks a project’s bugs, enhancements, discussions, etc.

It’s all relative

So why an issue to every commit?! This isn’t really the case, not every commit needs it’s own issue, but every commit should relate to an issue. Weather it’s existing, or you are creating it for this specific commit, there needs to be some sort of documentation of why the change is being made, what kind of change it is, and from there, all related change sets that relate to it.

If you have multiple files being edited, only commit files together if their changes are related. This helps the rollback process, when you can easily revert a changeset and all related changes are reversed, while unrelated changes are kept in their own revision.

Ad-Hoc changes are not only a challenge to track down if a bug arrises later, but it leads to a messy codebase where not all parties involved are aware of changes and their reasoning.

Meaningful messages tell a story

I’ll be honest, when it’s time to release, having the ability to just look at your commit messages and easily summarize what was changed is a godsend. It also helps you scope a release and the possible impact it may have. Each commit you make should have a meaningful message with it. “Updating Header” or “deleting stuff” doesn’t quite cut it. Not only does it make looking through issues later difficult, but it shows a lack of care and pride in what you just accomplished. I’ll be honest, I’ve done it once or twice, but try not to make it a habit.

Tools to do the job

Most developers have a few things in the air at once, and what happens if you have multiple changes to a file, but you only want to commit part of it!? These changes aren’t related and in fact, belong to different issues?! What is a developer to do? git add -p to the rescue. This command allows you to commit specific parts of a file, instead of all changes in the file. This is a great way to work in parallel, while keeping your commits tied to separate issue.

So be sure to write up that bug, enhancement, or feature next time you start coding and drop some project requirements in there while you are at it. Let’s focus on making your projects as manageable as possible.

What are some of your practices when it comes to issue tracking and commits?

Post Promoter Pro

Posted by Chris Klosowski

Hi, I'm Chris Klosowski. Currently I am a Lead Developer of Easy Digital Downloads, where we build the easiest way to sell digital products with WordPress.

I am also the person behind Post Promoter Pro, the most effective way to promote your WordPress Content.

4 Comments

  1. I often spend a lot of extra time pre-planning a project in the form of issues (or Trello cards for project-level stuff). Most commits are pre-meditated somewhere else at least this way. But, I don’t practice often referencing them in commits. Can’t count the times I’ve seen a commit and thought to myself “Where did this come from?” Good tip!

    Reply

    1. Thanks Aubrey, I did fail to mention some other tools for tracking changes and ideas but you bring up a great one…Trello.com! I know the Easy Digital Downloads team uses Trello extensively and while I’ve only used it from time to time, I like what I see. Thanks for mentioning it.

      Reply

  2. Any idea how to “commit part” using a GUI like SmartGit or PHPStorm? sounds like a good idea, just not sure how to implement since I’m not a CLI person.

    Reply

    1. According to a few sources I found, partial file commits (the -p flag) are possible in SmartGit with the Local|Index Editor. I’ve not tested this personally, but will give it a shot when I have a few minutes.

      Reply

Leave a reply

Your email address will not be published. Required fields are marked *