Ejemplo n.º 1
0
        private void FixChild(Dep currentParrentDep, string childConfiguration)
        {
            RemoveDepLine(childConfiguration, currentParrentDep, false);
            var parser           = new DepsYamlParser(new FileInfo(Directory.GetParent(yamlPath).FullName));
            var hadInSameSection = parser.GetDepsFromConfig(childConfiguration).Deps.Where(d => d.Name == patchDep.Name).ToList();

            if (!hadInSameSection.Any())
            {
                return;
            }
            if (hadInSameSection.Count > 1)
            {
                ThrowDuplicate();
            }
            var had = hadInSameSection.First();

            RemoveDepLine(childConfiguration, had, true);
            if (GetDepLine(had) == GetDepLine(currentParrentDep))
            {
                return;
            }
            if (FindLca(had, currentParrentDep).Configuration == currentParrentDep.Configuration)
            {
                return;
            }
            AddDepLine(childConfiguration, had, true);
            AddDepLine(childConfiguration, currentParrentDep, false);
        }
Ejemplo n.º 2
0
        private bool TryReplaceInSameSection(string patchConfiguration)
        {
            var parser           = new DepsYamlParser(new FileInfo(Directory.GetParent(yamlPath).FullName));
            var hadInSameSection = parser.GetDepsFromConfig(patchConfiguration).Deps.Where(d => d.Name == patchDep.Name).Distinct().ToList();

            if (!hadInSameSection.Any())
            {
                return(false);
            }
            if (hadInSameSection.Count > 1)
            {
                ThrowDuplicate();
            }
            var was      = hadInSameSection.First();
            var shouldBe = FindLca(patchDep, was);

            ReplaceDepLine(patchConfiguration, was, shouldBe);
            FixChildren(patchConfiguration);
            return(true);
        }