Checklist before merging / pushing changes to main branch

In the various git workflows you use, you always have a main branch, reserved for the stable code, the mainstream deployments and the version tagging. We touch these branches with precaution and care, right. Now in the agile development process we need to do rebases and merges often. That’s the necessary part. Now these rebases and merges lead us to conflicts and we try to resolve them. Now there is this checklist I wanted to share with you, this I generally follow to make sure that I am not committing/pushing any bad code. Just before pushing my merged/rebased branch, I search the following strings in the full codebase and remove/fix them as required;

  • “<<<<”
  • “>>>>”
  • “====”
  • “console.log”
  • Print statements

When you run into a conflict you get conflicted diff separated by clear line breaks containing “<<<<” , “====” and “<<<<” text.

<<<<<<< HEAD:mergetest
This is my third line
=======
This is a fourth line I am adding
>>>>>>> 4e2b407f501b68f8588aa645acafffa0224b9b78:mergetest

Searching for these strings in the full codebase ensures that you have not accidentally left any unresolved conflicts and marked it resolved. This also makes sure that when you have properly resolved the conflicts, you have also removed these line breaks which are not required any more.

Console log statements

I use console.log all the time. For dry running and for debugging, console.log always comes in handy. It is better than alert() , it is quite, fast and does not add a breakpoint. But you should not save any unnecessary console logs. They can make your page heavy and slow. User do not see or interact with that, so it is not required. You know Firefox 3.6 with firebug used to break; if your code have a console.log statement and your dev tools is not open while js is executing. But we came much ahead of FF3.6 today, lets get back to the checklist:
Now, searching for “console” in complete codebase ensures that you have not left any unrequired console statements.

Print statements

Depending on the language of our app, either it be pyhon, ruby or php or anything, we use print statements. But yes, they are just for development help or debugging. We do not need them on staging or production. So by searching for print statements depending upon your language, you will clear out the last thing too !!

Let me know your thoughts on this, there will be some points I need to add to this checklist . . .

Leave a Reply

  • (will not be published)