Kentico sneaky feature: diff your CI XML files with Git
Kentico’s Continuous Integration module is extremely powerful and makes development teams’ lives much easier. But the popular version control system Git presents some issues we need to work around.
November 2015: Kentico released its Continuous Integration (CI) module with Kentico 9, to wild cheering and screaming of developers around the globe. Dev teams were now able to work on their own local databases, serialise all of their database objects (such as templates, transformations, forms, even pages) as XML files in a CIRepository folder in the file system, which allowed them to use source control to track database changes... for some objects.
November 2016: Kentico’s platform team, led by the fearless Michal “King” Kadak, expanded the CI module in K10 to support practically all objects, even your own custom modules, with advanced filtering rules. Continuous Integration Nirvana reached!
Or was it? Do you use Git?
.NET serialises objects (saves a representation of them as flat text files) using UTF-16 encoding - a text format which allows you to use all sorts of fancy characters, not just the standard ASCII set.
Git only supports UTF-8 encoding for text files. Other encoding, such as UTF-16, results in the files being recognised as generic binary files (such as ZIP or EXE files), so it can’t compare the contents line by line and tell you what’s changed (or “diff” them).
This means it can be very difficult to manage merge conflicts in Git when developing in teams, which is unfortunately one of the main benefits of using the CI module.
TL;DR: By default, Git doesn’t like the XML files the Kentico CI module produces.
- Git can't see what has changed in a CI file:
- Developers are sad.
It’s important to note that this isn’t a bug - it’s a limitation of Git, which just happens to be a very popular version control system used by developers.
Other version control systems or plugins can handle those UTF-16 files fine, but like so many other cool and trendy dev teams, we use Git.
It’s possible to diff files using third-party software on your local machine, such as KDiff3, but the most popular cloud-based git repository hosting services - such as Github, Gitlab, and Bitbucket Cloud - don’t give you that option.
(Hot tip from fellow MVP Kristian Bortnik - the locally hosted version of BitBucket does give you the option of converting text files to UTF-8 so they can be diffed, so if that’s what you’re using, you’re in luck!)
As of Kentico Hotfix 10.0.11, you are able to change the encoding used by the CI module to UTF-8!
Once you've applied the hotfix (available for download here):
- Add the web.config key
<add key="CMSCIEncoding" value="utf-8" />
- Reserialize your objects
- Commit it and push it
It really is that easy. Just add a web.config key.
- Pull requests inside BitBucket now showing detailed diffs on XML files
- Developers are happy!
Thanks to the Kentico team as always, for listening to the dev community! It’s great to know that they prioritise the developers’ experience, and it’s also a great example of how beneficial the weekly hotfixes can be from Kentico.
Want more? Here are some other blog posts you might be interested in.
Creating a digital strategy roadmap
A good roadmap not only outlines what you want to achieve with your digital strategy, but sets out the detail of how you're going to get there. Here we provide guidance on how to do it, along with a downloadable Digital Roadmap Toolkit.
Web design trends for 2019: Part I – Purposeful motion
In this three-part series on design and UX trends, Luminary Design Director Tess French weighs in with some thoughts on the web design elements we’re likely to see more of in 2019.