Category Archives: Tooling Api

Code Comparison Utility

What happens when the code gets pushed to production which you don’t want to. Crisis !!!. This normally happens when developer A works on some file and developer B make changes to same file (mostly for bug fix/new req). So developer A thinks that only he had worked on the file and it is safer to move changes to production but when page is pushed to production unexpected things starts because of unwanted changes being pushed to production. How such situations can handled? Before any code movement to production comparing the code copy from Sandbox with Production. There are good tools available to do that like WinMerge,SVN, Eclipse inbuilt code comparison. This takes time to take fresh copy from sandbox and production and then comparing to find out which changes are getting pushed. I normally do this code comparison before moving any code to production. Being a lazy person sometimes I skip comparison because it takes time (most precious commodity :P). So to make this process faster I have used tooling api to make things automated. Here is the page developed which takes Source org (Sandbox) and Target Org (Production Org) credentials for signing in. Once you are logged in, it provides list of metadata components (currently ApexClasses,ApexPages and Triggers) to select. On selection of component it pulls the fresh code from both the orgs and gives a code comparison.

For comparing code I have used this awesome library Mergely created by Jamie Peabody Github repo : https://github.com/wickedest/Mergely

Here is the demo url : http://kmforce-developer-edition.ap1.force.com/sfcompare

You will be able to see code comparison in below manner:compare

Here left panel would be Target org (Production) and right panel would be source org (Sandbox)

Source code:

1. Controller

2. Page

If you find this utility useful, please comment and let me know your views/suggestions on it.

Advertisements