Synchronize Specification File Changes With Generated Source Code
You can use this function to bring new changes from the specification file to the chaincode source files (model and controller). This function works with both TypeScript and Go projects.
Note:
- Code sync is unidirectional - you can bring changes from your specification file into your chaincode project, but not the other way around. Changes made in your chaincode project remain as-is after the synching process.
- This command only works if the chaincode project has been scaffolded using a specification file. Ensure you do not delete, rename or move the specification file if you plan to sync any changes from the specification file to the source code in future.
To synchronize your specification and chaincode files:
- In the Specifications pane, select the specification file that you've updated to open its Specification Details pane. At the top of the pane, click Chaincodes to open the pane showing which chaincodes this specification has been used to generate.
- Select the Sync checkbox beside each chaincode you want to update with these changes. You can synchronize more than one chaincode generated from a specification file at a time. Click Synchronize.
Resolving Conflicts
Since you can edit both the synchronization files and chaincode files, it's possible to end up with conflicts where the updated specification file would overwrite a change you've made to the chaincode file. In these cases, when you attempt to synchronize an error displays stating there's a conflict. You can use the Conflicts pane to resolve these.
- On the Conflicts pane, click the name of the chaincode file where the conflicts exist. The file will open in an editor with the conflicts highlighted.
In the example shown,
Marble124
is in the specification file, andMarble123
is in the chaincode model file. - Above the conflict are your list of options. Click Accept Current Change to override the specification file and use what is currently in the chaincode file. Click Accept Incoming Change to override the chaincode file and use what is currently in the specification file.
- Return to the Conflicts pane. Select the Sync checkbox next to the conflict name, and click Confirm Changes. If you have multiple conflicts, resolve all of them before before clicking Confirm Changes.