Promote and Compare

There are a lot of ways to release software, some go straight to production on merging into the master branch. While others have a much more manual process. There are tradeoffs for all the different ways of shipping code that are out of the scope of this post. Stated briefly, the PR before merging into master is nice because it allows you to compare master and the feature or staging branch you are merging into it. However having master go into (which is usually what heroku recommends in their pipelines) a staging environment and then promoting that environment (since you "know" it works) to production is a slightly different but equally valid way of doing this.

If your release system promotes a staging environment to a production environment you may sometimes ask yourself the following question:

This code I am about to promote... how different is it from prod?

Maybe you are a lone developer on a project and you put some code on staging but it wasn't working well enough for you to go to production. You then casually go on a two week vacation and once you come back you are resigned to muddling through the git repo of commits to figure out what the diff is.

There are many ways to do this! But given a lot of code lives on GitHub nowadays I thought I would show you a simple trick for comparing between any two commits. A GitHub url in the following format will generate a diff between the two commits. The way to read it is what has happened since to and including

In summary, use an url of the format<owner>/<repo>/compare/<SHA proposed>..<SHA current prod> where the sha must be at least 4 significant characters and you will get a diff between any two commits.

Update: if you look at the activity feed on heroku they generate a link to the diff on github for you. It‘s still worth knowing how to do it manually but still very useful.