Merge from development environment to production without overwriting production specific code

Viewed 32

I have a windows forms application that has 2 branches, master which is hooked up to our production environment and dev which is hooked up to our development environment. There are a few visual differences between the 2 branches, the master branch has a red background and a 'Live' label and the dev branch has a blue background and a 'Pilot' label, to easily show users which application they're using. The applications also have a list of web references, however between the 2 branches the web reference URLs are different, with the master branch containing web references that use our production environment and the dev branch containing web references that point to our develop environment.

When I go to make add a new feature or fix a bug, I create a new branch based off the dev branch. I add the code for my new feature, test it out, and then when I think it's ready I merge it into the dev branch, which works just fine. I run into problems through when I try to merge the new branch into the master branch. It overwrites the master branches UI elements, like the label and background color and the web reference URLs, so then after the merge I end up having to go through and switch all the web reference URLs and UI elements in the master branch back to the way they should be for Live.

The way I've gotten around this in the past is cherry picking the commits from the new branch into the master branch, but I know this isn't best practice and can become quite complicated depending on how many commits I've made to the new branch.

I'm the sole developer on my team and I'm not sure what the best way to resolve this issue would be. In the projects application settings file I created an 'Environment' variable and in the forms load event I have the following code that dictates what color the form is and which URL each of the web references uses based on the 'Environment' variable, but this also doesn't seem like the best way to do things and it doesn't fix my initial issue, when I make a new branch off of my dev branch and then merge it into my master branch the 'Environment' variable is still being overwritten in master, so after the merge I'm still having to go in and change to 'Environment' back to Live in master. Any help or advice would be much appreciated.

Application Settings Image

   public Form1()
    {
        InitializeComponent();

        if (Properties.Settings.Default.Enviroment == "Live") //In the production app
        {
            this.BackColor = System.Drawing.Color.Red;
            baqClient.Url = "http://LiveApplication/RunBAQ.ASMX";
            CheckOutBOMSvcClient.Url = "http://LiveApplication/CheckOutBOM.asmx";
        }
        else //In the development app
        {
            this.BackColor = System.Drawing.Color.LightBlue;
            baqClient.Url = "https://PilotApplication/RunBAQ.ASMX";
            CheckOutBOMSvcClient.Url = "http://PilotApplication/CheckOutBOM.asmx";
        }
    }
0 Answers
Related