External Sync / How to... / Resolving conflicts / Simultaneous Modification of a Template / Overlapping areas (conjunction)

Simultaneous changes to a template, overlapping areas (conjunction)

Table of contents

This scenario demonstrates the approach for handling conflicts where multiple developers working on a template at the same time leads to different changes being made to the same area of an element (e.g., each developer makes a different change to the same line) in the local working versions of a template.

In the event of conflicting changes to overlapping areas in the same file, the conflict must be rectified manually by the user outside of FirstSpirit by transferring the local changes to the Git repository. In this case, the user must decide which version (the one initially transferred to the repository or the local version) should be kept.

Initial situation

The FirstSpirit project includes a page template page_text, whose presentation channel definition “HTML” contains the following text:

Line 1
Line 2
Line 3
Line 4
Line 5

The version of the page template is the same in both developers’ project instances.

How the conflict occurs

Developer A

  1. Modifying a FirstSpirit element
    Developer A changes the content of the presentation channel in the page template page_text:
    Line 1
    Line 2 A
    Line 3
    Line 4
    Line 5
  2. Exporting changes into the file system
    Developer A uses fs-cli to export the current version of the project into the local file system (Git repository)
    fs-cli -p DevProject -sd "D:\Git\DevProject" export templatestore
  3. Transferring changes to the Git repository
    Developer A transfers the changes to the Git repository
    git commit -a -m "changed page_text"
    git push

Developer B

  1. Modifying a FirstSpirit element
    Developer B changes the content of the presentation channel at same point in the text that Developer A changed, but adds different content:
    Line 1
    Line 2 B
    Line 3
    Line 4
    Line 5
  2. Exporting changes into the file system
    Developer B uses fs-cli to export the current version of the project into the local file system
    fs-cli -p DevProject -sd "D:\Git\DevProject" export templatestore
  3. Transferring changes to the Git repository
    Developer B transfers the changes to the Git repository
    git commit -a -m "export page_text"
    git push

$ git push
To ssh://firstspirit.example/externalsync
! [rejected] myBranch -> ts/sync-test (non-fast-forward)
error: failed to push some refs to 'ssh://fsgit@ssh://test.domain.com/git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Conflict resolution

Update

Updating the working directory against the Git repository
Developer B updates the local working version so that it is in line with the repository:
git pull

Developer B now receives a message from the Git client to say that a conflict has occurred: The repository contains another change at another point in the file to be checked in (the change made by Developer A) and this change is not in the local version (from Project B).

Resolving the Git conflict

The resolution of this conflict requires manual intervention by Developer B as the Git client is unable to decide which of the two versions should be kept.

Message from the Git client in the command line, e.g.:

CONFLICT (content): Merge conflict in TemplateStore/PageTemplates/page_text/ChannelSource_HTML_html.html
Automatic merge failed; fix conflicts and then commit the result.

At this point Developer B must decide which version (the one in the local project instance or the version already transferred to the repository by Developer A) should be used as the definitive version. If he decides, for example, to keep his own change to the template, then he must perform a check-out using the Git client so that the local versions of the files are kept for the conflicting case:

git checkout --ours *

The file TemplateStore/PageTemplates/page_text/ChannelSource_HTML_html.html with the changes by Developer B is therefore seen as definitive; the changes to the file in the repository that stem from Developer A are ignored.

Import

Developer B should now check the result of the completed check-out and then transfer the changes to the page template in the repository:

Importing the contents from the file system to the FirstSpirit project
Developer B
fs-cli -p DevProject -sd "D:\Git\DevProject" import

Checking the version of the project
Developer B

Export

Exporting changes into the file system
Developer B uses fs-cli to export the current version of the project into the local file system
fs-cli -p DevProject -sd "D:\Git\DevProject" export templatestore

Commit / Push

Transferring changes to the Git repository
Developer B transfers the changes to the Git repository
git commit -a -m "export page_text"
git push

Next steps

The conflict is resolved. Developer B does not have to do anything else at this point.

Developer A

If Developer A restarts development work later on, then he should complete the following:

  1. Updating the local Git repository
    Developer A
    Update the local working version so that it is in line with the repository:
    git pull
  2. Importing the contents from the file system to the FirstSpirit project
    Developer A
    fs-cli -p DevProject -sd "D:\Git\DevProject" import

The page template page_text in the version that contains the changes by Developer B is now in both Developer A’s local project and Developer B’s local project:

Line 1
Line 2 B
Line 3
Line 4
Line 5

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.5 | Data privacy