-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When changing Unicorn configuration it gives new paths for the yml files, resulting in errors in package #31
Comments
Could you please provide a few sample items in the source and the target folders that would illustrate a problem or describe the scenario in more details? As far as I understand, you have something like this: Source: Target: And the resulting package does not contact "Delete Item" operation? |
Attached a zip of a very simple YML testcase, a template where I removed 1 field, while i also change the configuration name of the Unicorn, resulting in a different path. Creating a package of this source and target, results in the field not being deleted. I see multiple other similar problems though, when using Sitecore path rather than Sitecore ID for comparison. Including moved and renamed items (I haven't tested those yet though). |
I've ran Courier with the following command (note "-r" for Rainbow): Sitecore.Courier.Runner.exe -s C:\Source -t C:\Target -o C:\Package.update -r and here's what I get under changed items:
|
That is correct, and as expected. It is the deleted field (field2) which is no - it is the standard value no longer present. t in the update package (should have been a delete item) |
Are you talking about "__Standard Values" item? I can see it is present (and is identical) in both source and the target. Technically, the "target" folder in your example contains corrupt serialization (as Standard Values in that folder should not have the Field2 standard value if everything was serialized correctly). |
I am no longer at my computer. You may be right about the corrupt serialization, I made it by hand, as my "production" example is very large and contains sensitive data. What this example source should have been was: My target was the same, except Field2 is removed (resulting in it's standard value being gone as well) and the unicorn configuration is renamed to 2. What should happen here is 1 item change (Field2 value removed from standard values) and 1 item delete (Field2) - but the item delete is missing |
I've had the chance to check up on the example I provided now. The target does not have a Field2 standard value, only Field1 (which is still present). I guess what you're talking about is that the changeItemCommand on "__Standard Values" item created by Sitecore Courier end up having a deleteFieldCommand on the no longer existing field? |
Ok, I see where the issue is now, thanks! 👍 I'll review it and get back with my comments soon. |
Thanks, I've added quick fix for this scenario (published as Release v1.2.3). The diff algorithm is not ideal and PRs with improvements are welcome. especially if they are also covered by unit tests. |
I have created a change, I don't have good enough datasets to test at home, but I will test it tomorrow and commit if it works as expected. I am however in doubt how you want the unit tests to run? I don't see any examples in the repository. Do you have any current examples? (which I would need to test my code on as well, to make sure it doesn't break anything else I did not account for). |
I've done a bit more testing. Would still love to have it tested if you have any unit tests ready. Just leaving the notes I made for the commit here for later use: Changed DiffGenerator quite a bit. Some thoughts behind the changes
|
Please just use a forked repository and create a pull request when the change is ready. I'll take a look into creating some unit tests over the weekend. |
Ahh alright, never tried forks. Created one and made a pull request. For now I've made an entirely new DiffGenerator, with a new commandlineoption -n to use it (meaning it's only enabled in commandline tool). You can review and decide whether to implement it. I have done a large amount of testing, by comparing 2 different local development sites, which i both serialized with Unicorn and Sitecore. What I did was take a copy of the App_Config, bin and Views folders, as well as a full serialization of master:/sitecore/System folder. I did this for the current master version as well as the forked version. source project: target project: The results were that for both versions of the serialization, some items were missing in the deleteitems folders (some languages and some other settings). Other than that, there were namechanges to 2 file, MongoDB.Bson.XML and MongoB.Driver.XML - these were changed from uppercase extension to lowercase extension. The "old" version considered these as changed, which results in no name change on the file. My version does a delete and add. So the filenames are exactly the same again. I added some stopwatches as well to check time. But the DiffGenerator itself only took around 3-4 seconds with either serialization and either implementation, so even though the new was a tad faster, it was too little to consider it any meaningful optimization. Have a look, I'll be happy to answer any questions you might have. |
Thanks! I've merged the pull request, will do some further testing and then include into the next release. I've also added a few sample diff generation tests at DiffGeneratorTests.cs |
I've added a unit test to the class, it's set to run with NewDiffGenerator and works, but if you change it to the old DiffGenerator (commented out) the test fails.
|
Merged in #42 |
We're trying out Sitecore Courier for a new project. In this process we've been changing the Unicorn config, resulting in the exact same items being stored on different filepaths in the source and target library.
When this is the case, a deleted item won't be kept as an item deletion, but is removed by the line:
commands.RemoveAll(c => c is DeleteItemCommand && ((DeleteItemCommand)c).ItemPath.StartsWith(command.Deleted.ItemPath));
I took a quick look at the sourcecode, and considered doing a change myself, but wasn't sure if I'm misunderstanding something.
Basically I am confused by the entire GenerateDiff. Why compare all items of all types to eachother, and make way more differences than needed, and try to clean it afterwards?
In my mind, it would be simpler first taking all source items derived from ContentDataItem and comparing these to target ContentDataItem by Sitecore ID rather than path, and then just explicitly creating an add/remove/update based on differences.
Files would still need to be done exclusively on path as currently, but I think i'd work with sets on this as well.
If you wish, I'd be happy to do a pull request for such a change. I'm just unsure whether there's some reason I don't see for doing it the current way.
The text was updated successfully, but these errors were encountered: