1

Currently on my project, we are updating to react 17 and the testing library we use(enzyme to react testing library). In this process will we need to update multiple tests and files. However I don't want to do the upgrade in our main branch.

If I create a new branch that our team works off of - we won't be able to keep it updated with our main branch’s code(which we will continue to work on). That is not a viable solution, since that will lead to multiple merge conflicts and issues.

Another option is to update react/testing library on our main branch and ignore tests/files we need to get the app to work and build to pass. Then just work off of our main branch and update the code.

Ideally I would like:

  • A separate branch that devs can merge into with upgrades
  • The separate branch to be able to stay up to date with develop
  • Merge branch when all work is complete
  • Ability to work off main branch without upgrades

From my understanding there is no standard way of doing this. I looked into git worktree and not sure if that does what I need. Any recommendations on the best way of accomplishing this?

1
  • 1
    I’m voting to close this question because it's nothing to do with Craft Dec 17, 2021 at 10:21

1 Answer 1

1

I don't quite understand your situation – why is part of your team working on parts of the app that are in the process of being upgraded? Aren't you duplicating work there? It makes no sense to work on a component that is currently being upgraded and requires changes to work with the new version. Wouldn't it be easier to declare a feature-freeze and have everyone participate in upgrading to the new version, update their components and tests and be done with it much quicker?


If you really need to continue working on new features while you're in the process of upgrading the app, you're gonna want to do the upgrade in a separate branch. You won't find a perfect solution to keep two diverging branches of the same app and then merge them magically at the end. Instead, you want to avoid a huge merge conflict in the end. Instead, try to keep the two branches in sync by merging regularly.

Let's say you have two branches, main (the current version of the app) and upgrade (the react 17 version with the new testing library). If new features are developed on main (I hope you're using feature branches and PRs to get new features out), you want to merge the main branch into the upgrade branch regularly. For example, merge the main branch into upgrade once a day and fix any merge conflicts right then and there. This ensures your branches aren't getting out of sync. Once the upgrade branch is ready to replace the old version of the app, merge it into main and delete the upgrade branch. Now everyone can continue working without a huge disruption while someone fixes hundreds of merge conflicts.

If you're getting tons of complicated merge conflicts during the daily merges, this is a strong sign that you're duplicating efforts. One person working on a new feature in the old version that will immediately require updates in the new version doesn't make sense. But if you for some reason can't avoid this, minimizing the pain by merging regularly and doing the leg-work of fixing any conflicts right there is the way to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.