从开发环境合并到生产而没有覆盖生产特定代码

发布于 2025-02-10 01:53:03 字数 1488 浏览 3 评论 0原文

我有一个Windows Forms应用程序,该应用程序具有2个分支机构,主体已连接到我们的生产环境和开发环境中,并连接到我们的开发环境。两个分支之间存在一些视觉差异,主分支具有红色背景和一个“实时”标签,而开发部门具有蓝色背景和一个“飞行员”标签,以轻松显示其应用程序使用的用户。这些应用程序还具有Web参考的列表,但是在两个分支之间,Web参考URL不同,主分支包含使用我们生产环境的Web参考和包含指向我们开发环境的Web参考的Dev分支。

当我要添加新功能或修复错误时,我会根据开发分支创建一个新分支。我为我的新功能添加代码,对其进行测试,然后当我认为它准备就绪时,我将其合并到Dev分支中,这很好。当我尝试将新分支合并到主分支中时,我会遇到问题。它覆盖主分支UI元素,例如标签和背景颜色以及Web参考URL,因此,在合并之后,我最终不得不经过并切换主分支中的所有Web参考URL和UI元素他们应该活着。

我过去解决这个问题的方式是樱桃从新的分支机构挑选出大师分支,但我知道这不是最好的练习,并且可能会变得非常复杂新分支。

我是团队中唯一的开发人员,我不确定解决这个问题的最佳方法是什么。在项目应用程序设置文件中,我创建了一个“环境”变量,在“表单加载事件”中,我有以下代码,该代码决定表单是什么颜色以及每个Web参考的URL基于“环境”变量的使用,但是此当我将新的分支从Dev分支上脱离并将其合并到我的主分支中时,似乎也不是做事的最佳方法,也无法解决我的最初问题。在大师中,因此,合并后,我仍然必须进入并更改为“环境”重新生活在主人中。任何帮助或建议将不胜感激。

应用程序设置图像

   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";
        }
    }

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";
        }
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文