<commit_before>﻿using System.Diagnostics.CodeAnalysis;
using Rainbow.Model;
using Rainbow.Storage.Sc.Deserialization;
using Sitecore.Data;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.StringExtensions;
using Unicorn.Logging;

namespace Unicorn.Deserialization
{
	[ExcludeFromCodeCoverage]
	public class DefaultDeserializerLogger : IDefaultDeserializerLogger
	{
		private readonly ILogger _logger;
		public DefaultDeserializerLogger(ILogger logger)
		{
			_logger = logger;
		}

		public virtual void CreatedNewItem(Item targetItem)
		{

		}

		public virtual void MovedItemToNewParent(Item newParentItem, Item oldParentItem, Item movedItem)
		{
			_logger.Debug("* [M] from {0} to {1}".FormatWith(oldParentItem.ID, newParentItem.ID));
		}

		public virtual void RemovingOrphanedVersion(Item versionToRemove)
		{
			_logger.Debug("* [D] {0}#{1}".FormatWith(versionToRemove.Language.Name, versionToRemove.Version.Number));
		}

		public virtual void RenamedItem(Item targetItem, string oldName)
		{
			_logger.Debug("* [R] from {0} to {1}".FormatWith(oldName, targetItem.Name));
		}

		public virtual void ChangedBranchTemplate(Item targetItem, string oldBranchId)
		{

		}

		public virtual void ChangedTemplate(Item targetItem, TemplateItem oldTemplate)
		{
			_logger.Debug("* [T] from {0} to {1}".FormatWith(oldTemplate.Name, targetItem.TemplateName));
		}

		public virtual void AddedNewVersion(Item newVersion)
		{
			_logger.Debug("* [A] version {0}#{1}".FormatWith(newVersion.Language.Name, newVersion.Version.Number));
		}

		public virtual void WroteBlobStream(Item item, IItemFieldValue field)
		{

		}

		public virtual void UpdatedChangedFieldValue(Item item, IItemFieldValue field, string oldValue)
		{
			var itemField = item.Fields[new ID(field.FieldId)];
			if (itemField.Shared)
				_logger.Debug("* [U] {0}".FormatWith(itemField.Name));
			else if(itemField.Unversioned)
				_logger.Debug("* [U] {0}: {1}".FormatWith(item.Language.Name, itemField.Name));
			else
				_logger.Debug("* [U] {0}#{1}: {2}".FormatWith(item.Language.Name, item.Version.Number, itemField.Name));
		}

		public virtual void ResetFieldThatDidNotExistInSerialized(Field field)
		{

		}

		public void SkippedPastingIgnoredField(Item item, IItemFieldValue field)
		{
			
		}
	}
}<commit_msg>Add log message when a branch template is changed<commit_after>﻿using System.Diagnostics.CodeAnalysis;
using Rainbow.Model;
using Rainbow.Storage.Sc.Deserialization;
using Sitecore.Data;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.StringExtensions;
using Unicorn.Logging;

namespace Unicorn.Deserialization
{
	[ExcludeFromCodeCoverage]
	public class DefaultDeserializerLogger : IDefaultDeserializerLogger
	{
		private readonly ILogger _logger;
		public DefaultDeserializerLogger(ILogger logger)
		{
			_logger = logger;
		}

		public virtual void CreatedNewItem(Item targetItem)
		{

		}

		public virtual void MovedItemToNewParent(Item newParentItem, Item oldParentItem, Item movedItem)
		{
			_logger.Debug("* [M] from {0} to {1}".FormatWith(oldParentItem.ID, newParentItem.ID));
		}

		public virtual void RemovingOrphanedVersion(Item versionToRemove)
		{
			_logger.Debug("* [D] {0}#{1}".FormatWith(versionToRemove.Language.Name, versionToRemove.Version.Number));
		}

		public virtual void RenamedItem(Item targetItem, string oldName)
		{
			_logger.Debug("* [R] from {0} to {1}".FormatWith(oldName, targetItem.Name));
		}

		public virtual void ChangedBranchTemplate(Item targetItem, string oldBranchId)
		{
			_logger.Debug("* [B] from {0} to {1}".FormatWith(oldBranchId, targetItem.BranchId));
		}

		public virtual void ChangedTemplate(Item targetItem, TemplateItem oldTemplate)
		{
			_logger.Debug("* [T] from {0} to {1}".FormatWith(oldTemplate.Name, targetItem.TemplateName));
		}

		public virtual void AddedNewVersion(Item newVersion)
		{
			_logger.Debug("* [A] version {0}#{1}".FormatWith(newVersion.Language.Name, newVersion.Version.Number));
		}

		public virtual void WroteBlobStream(Item item, IItemFieldValue field)
		{

		}

		public virtual void UpdatedChangedFieldValue(Item item, IItemFieldValue field, string oldValue)
		{
			var itemField = item.Fields[new ID(field.FieldId)];
			if (itemField.Shared)
				_logger.Debug("* [U] {0}".FormatWith(itemField.Name));
			else if(itemField.Unversioned)
				_logger.Debug("* [U] {0}: {1}".FormatWith(item.Language.Name, itemField.Name));
			else
				_logger.Debug("* [U] {0}#{1}: {2}".FormatWith(item.Language.Name, item.Version.Number, itemField.Name));
		}

		public virtual void ResetFieldThatDidNotExistInSerialized(Field field)
		{

		}

		public void SkippedPastingIgnoredField(Item item, IItemFieldValue field)
		{
			
		}
	}
}
{'fraction_non_alphanumeric': 0.11789562645256708, 'fraction_numerical': 0.007183604479188675, 'mean_word_length': 5.015247776365946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4438166', 'n_tokens_mistral': 1705, 'n_tokens_neox': 1534, 'n_words': 329}