solutions

Conflicts

How Sturdy deals with and prevents conflicts.

When two (or more) developers are touching the same lines of code, Sturdy won't be able to automatically sync the code between the two developers.

As an example, imagine that we have a function Add that takes two ints and returns another int. Two colleagues, Frank and Sarah happen to both make changes to this function in parallel. Sarah changes the types to float64, and Frank changes the names of the arguments.

- func Add(a, b int) int
+ func Add(a, b float64) float64
- func Add(a, b int) int
+ func Add(x, y int) int

It's no longer possible to automatically sync these two changes as they are touching the same lines of code.

So what do you do?

Let's say that Sarahs changes are approved first, and she shares them with the rest of the team. The next time that Frank syncs new changes into his workspace, the conflict will be detected, and he'll have to decide how to resolve the conflict.

Resolving conflicts in Sturdy
Resolving Conflicts in Sturdy

For each file where there are conflicts, Frank will be given three options. He can either decide to keep only one version of the changes, keep the file as it looked before syncing, and override Sarahs changes. Or doing the opposite, allowing Sarahs changes to replace the one he made. If neither of these alternatives are good enough, Frank can resolve the conflict manually in his editor, and submit a manual resolution.

Resolving conflicts in Sturdy
Initiating a manual conflict resolution on Sturdy

Solving a conflict manually can look a bit intimidating, but is easy to do if you're familiar with Git. Sturdy exposes conflicts in a git-compatible format (using <<<<<<<, =======, and >>>>>>> as separators). Resolve the conflict in your local text editor, and when you're done, mark the conflict as done on Sturdy.

Resolving conflicts in Sturdy
Resolving a conflict manually in Sturdy

And that's how easy it is to resolve conflicts in Sturdy!