示例#1
0
        public void Copy_Non_Ignored_Solution_Files()
        {
            var sourceFolder      = Directory.GetParent(TestContext.CurrentContext.TestDirectory).Parent.Parent.Parent.FullName;
            var destinationFolder = _basePath + "/copy";

            if (Directory.Exists(destinationFolder))
            {
                Directory.Delete(destinationFolder, true);
            }

            Directory.CreateDirectory(destinationFolder);

            var source      = new DirectoryInfo(sourceFolder);
            var destination = new DirectoryInfo(destinationFolder);

            // Load the solution .gitignore file
            var ignores = new IgnoreList(sourceFolder + "/.gitignore");

            // Add an additional rule to ignore the .git folder
            ignores.AddRule(".git/");

            CopyWithIgnores(source, destination, ignores);

            // Do some very minimal checks and then just do some manual checking of the copy folder
            Assert.IsTrue(File.Exists(destinationFolder + "/MAB.DotIgnore/MAB.DotIgnore.csproj"));
            Assert.IsTrue(File.Exists(destinationFolder + "/MAB.DotIgnore.Test/MAB.DotIgnore.Test.csproj"));
            Assert.IsFalse(Directory.Exists(destinationFolder + "/MAB.DotIgnore/bin"));
        }
示例#2
0
        public void Add_Rule_Flags_Respected()
        {
            var directory = new DirectoryInfo(_basePath + @"\TEST");
            var list1     = new IgnoreList(new string[] { "x" });
            var list2     = new IgnoreList(new string[] { "x" });

            list1.AddRule("test");
            list2.AddRule("test", MatchFlags.CASEFOLD);
            Assert.IsFalse(list1.IsIgnored(directory));
            Assert.IsTrue(list2.IsIgnored(directory));
        }
示例#3
0
        public void Clone_Keeps_Match_Flags()
        {
            var original = new IgnoreList(new string[] { "README1.txt", "README2.txt" }, MatchFlags.PATHNAME | MatchFlags.CASEFOLD);

            original.AddRule("README3.txt", MatchFlags.NONE);
            var clone = original.Clone();

            Assert.IsTrue(clone.Rules[0].MatchFlags == (MatchFlags.PATHNAME | MatchFlags.CASEFOLD));
            Assert.IsTrue(clone.Rules[1].MatchFlags == (MatchFlags.PATHNAME | MatchFlags.CASEFOLD));
            // Should use PATHNAME because we assign this internally if it's not set
            Assert.IsTrue(clone.Rules[2].MatchFlags == MatchFlags.PATHNAME);
        }
示例#4
0
        public void Ignore_After_Dynamic_Add()
        {
            var ignoreList = new IgnoreList(new List <string> {
                "README1.txt"
            });

            ignoreList.AddRule("README2.txt");
            ignoreList.AddRules(new List <string> {
                "README3.txt", "README4.txt"
            });
            Assert.IsTrue(ignoreList.IsIgnored("README1.txt", true));
            Assert.IsTrue(ignoreList.IsIgnored("README2.txt", true));
            Assert.IsTrue(ignoreList.IsIgnored("README3.txt", true));
            Assert.IsTrue(ignoreList.IsIgnored("README4.txt", true));
        }