示例#1
0
 public void testError_CcTruncatedOld()
 {
     GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_CcTruncatedOld.patch");
     Assert.AreEqual(1, p.getFiles().Count);
     Assert.AreEqual(3, p.getErrors().Count);
     {
         FormatError e = p.getErrors()[0];
         Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity());
         Assert.AreEqual(
             "Truncated hunk, at least 1 lines is missing for ancestor 1",
             e.getMessage());
         Assert.AreEqual(346, e.getOffset());
         Assert.IsTrue(e.getLineText().StartsWith(
                           "@@@ -55,12 -163,13 +163,15 @@@ public "));
     }
     {
         FormatError e = p.getErrors()[1];
         Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity());
         Assert.AreEqual(
             "Truncated hunk, at least 2 lines is missing for ancestor 2",
             e.getMessage());
         Assert.AreEqual(346, e.getOffset());
         Assert.IsTrue(e.getLineText().StartsWith(
                           "@@@ -55,12 -163,13 +163,15 @@@ public "));
     }
     {
         FormatError e = p.getErrors()[2];
         Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity());
         Assert.AreEqual("Truncated hunk, at least 3 new lines is missing", e
                         .getMessage());
         Assert.AreEqual(346, e.getOffset());
         Assert.IsTrue(e.getLineText().StartsWith(
                           "@@@ -55,12 -163,13 +163,15 @@@ public "));
     }
 }
示例#2
0
        public void testError_GitBinaryNoForwardHunk()
        {
            GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_GitBinaryNoForwardHunk.patch");
            Assert.AreEqual(2, p.getFiles().Count);

            FileHeader fh0 = p.getFiles()[0];

            Assert.AreEqual("org.spearce.egit.ui/icons/toolbar/fetchd.png", fh0.NewName);
            Assert.AreEqual(FileHeader.PatchTypeEnum.GIT_BINARY, fh0.getPatchType());
            Assert.IsTrue(fh0.Hunks.isEmpty());
            Assert.IsNull(fh0.getForwardBinaryHunk());

            FileHeader fh1 = p.getFiles()[1];

            Assert.AreEqual("org.spearce.egit.ui/icons/toolbar/fetche.png", fh1.NewName);
            Assert.AreEqual(FileHeader.PatchTypeEnum.UNIFIED, fh1.getPatchType());
            Assert.IsTrue(fh1.Hunks.isEmpty());
            Assert.IsNull(fh1.getForwardBinaryHunk());

            Assert.AreEqual(1, p.getErrors().Count);
            FormatError e = p.getErrors()[0];

            Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity());
            Assert.AreEqual("Missing forward-image in GIT binary patch", e.getMessage());
            Assert.AreEqual(297, e.getOffset());
            Assert.AreEqual("\n", e.getLineText());
        }
示例#3
0
        public void testError_BodyTooLong()
        {
            GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_BodyTooLong.patch");
            Assert.AreEqual(1, p.getFiles().Count);
            Assert.AreEqual(1, p.getErrors().Count);

            FormatError e = p.getErrors()[0];

            Assert.AreEqual(FormatError.Severity.WARNING, e.getSeverity());
            Assert.AreEqual("Hunk header 4:11 does not match body line count of 4:12", e.getMessage());
            Assert.AreEqual(349, e.getOffset());
            Assert.IsTrue(e.getLineText().StartsWith("@@ -109,4 +109,11 @@ assert"));
        }
示例#4
0
        public void testError_TruncatedNew()
        {
            GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_TruncatedNew.patch");
            Assert.AreEqual(1, p.getFiles().Count);
            Assert.AreEqual(1, p.getErrors().Count);

            FormatError e = p.getErrors()[0];

            Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity());
            Assert.AreEqual("Truncated hunk, at least 1 new lines is missing", e.getMessage());
            Assert.AreEqual(313, e.getOffset());
            Assert.IsTrue(e.getLineText().StartsWith("@@ -236,9 +236,9 @@ protected "));
        }
示例#5
0
        public void testError_DisconnectedHunk()
        {
            GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_DisconnectedHunk.patch");
            Assert.AreEqual(1, p.getFiles().Count);
            Assert.AreEqual(1, p.getErrors().Count);

            FileHeader fh = p.getFiles()[0];

            Assert.AreEqual("org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java", fh.NewName);
            Assert.AreEqual(1, fh.Hunks.Count);

            Assert.AreEqual(1, p.getErrors().Count);
            FormatError e = p.getErrors()[0];

            Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity());
            Assert.AreEqual("Hunk disconnected from file", e.getMessage());
            Assert.AreEqual(18, e.getOffset());
            Assert.IsTrue(e.getLineText().StartsWith("@@ -109,4 +109,11 @@ assert"));
        }
示例#6
0
        public void testError_GarbageBetweenFiles()
        {
            GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_GarbageBetweenFiles.patch");
            Assert.AreEqual(2, p.getFiles().Count);

            FileHeader fh0 = p.getFiles()[0];

            Assert.AreEqual("org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryConfigTest.java", fh0.NewName);
            Assert.AreEqual(1, fh0.Hunks.Count);

            FileHeader fh1 = p.getFiles()[1];

            Assert.AreEqual("org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java", fh1.NewName);
            Assert.AreEqual(1, fh1.Hunks.Count);

            Assert.AreEqual(1, p.getErrors().Count);
            FormatError e = p.getErrors()[0];

            Assert.AreEqual(FormatError.Severity.WARNING, e.getSeverity());
            Assert.AreEqual("Unexpected hunk trailer", e.getMessage());
            Assert.AreEqual(926, e.getOffset());
            Assert.AreEqual("I AM NOT HERE\n", e.getLineText());
        }