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

3 thoughts on “Code Comparison Utility

  1. sri February 17, 2015 at 8:09 pm Reply

    Hi

    Controller code is NOT working, for example line 40 and 70 are broken, can you update with working code without truncation issues

  2. smachhewar February 18, 2015 at 3:21 am Reply

    Hi Sri,

    On line no 40 session id is obtained and on line no 70, ApexClass as a metadata item is added. You can checkout the github raw version of code at https://gist.githubusercontent.com/kiran-machhewar/da6ec2e8d65bf41ec2a4/raw/SFCompareController
    Let me know exactly which code has truncation issues because this the same code which has been used in the demo page controller.
    Please remember one thing that you need to create one connected app for client id and client secrete key.

  3. SutoCom February 20, 2015 at 1:01 pm Reply

    Reblogged this on SutoCom Solutions.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: