Exemplo n.º 1
0
        public void testParse_OnlyLFMessage()
        {
            RevCommit c = create("\n");

            Assert.AreEqual("\n", c.getFullMessage());
            Assert.AreEqual(string.Empty, c.getShortMessage());
        }
Exemplo n.º 2
0
        public void testParse_ShortLineOnlyNoLF()
        {
            const string shortMsg = "This is a short message.";
            RevCommit    c        = create(shortMsg);

            Assert.AreEqual(shortMsg, c.getFullMessage());
            Assert.AreEqual(shortMsg, c.getShortMessage());
        }
Exemplo n.º 3
0
        public void testParse_NoMessage()
        {
            string    msg = string.Empty;
            RevCommit c   = create(msg);

            Assert.AreEqual(msg, c.getFullMessage());
            Assert.AreEqual(msg, c.getShortMessage());
        }
Exemplo n.º 4
0
        public void testParse_ShortLineOnlyEmbeddedAndEndingLF()
        {
            const string fullMsg  = "This is a\nshort message.\n";
            const string shortMsg = "This is a short message.";
            RevCommit    c        = create(fullMsg);

            Assert.AreEqual(fullMsg, c.getFullMessage());
            Assert.AreEqual(shortMsg, c.getShortMessage());
        }
Exemplo n.º 5
0
        public void testParse_ShortLineOnlyEmbeddedLF()
        {
            const string fullMsg  = "This is a\nshort message.";
            string       shortMsg = fullMsg.Replace('\n', ' ');
            RevCommit    c        = create(fullMsg);

            Assert.AreEqual(fullMsg, c.getFullMessage());
            Assert.AreEqual(shortMsg, c.getShortMessage());
        }
Exemplo n.º 6
0
        public void testParse_GitStyleMessage()
        {
            const string shortMsg = "This fixes a bug.";
            const string body     = "We do it with magic and pixie dust and stuff.\n"
                                    + "\n" + "Signed-off-by: A U. Thor <*****@*****.**>\n";
            const string fullMsg = shortMsg + "\n" + "\n" + body;
            RevCommit    c       = create(fullMsg);

            Assert.AreEqual(fullMsg, c.getFullMessage());
            Assert.AreEqual(shortMsg, c.getShortMessage());
        }
Exemplo n.º 7
0
        public void testParse_WeirdHeaderOnlyCommit()
        {
            var b = new StringBuilder();

            b.Append("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n");
            b.Append("author A U. Thor <*****@*****.**> 1218123387 +0700\n");
            b.Append("committer C O. Miter <*****@*****.**> 1218123390 -0500\n");

            var c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));

            c.parseCanonical(new GitSharp.Core.RevWalk.RevWalk(db), b.ToString().getBytes("UTF-8"));

            Assert.AreEqual(string.Empty, c.getFullMessage());
            Assert.AreEqual(string.Empty, c.getShortMessage());
        }
Exemplo n.º 8
0
        public void testParse_implicit_UTF8_encoded()
        {
            RevCommit c;

            using (var b = new BinaryWriter(new MemoryStream()))
            {
                b.Write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8"));
                b.Write("author F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("UTF-8"));
                b.Write("committer C O. Miter <*****@*****.**> 1218123390 -0500\n".getBytes("UTF-8"));
                b.Write("\n".getBytes("UTF-8"));
                b.Write("Sm\u00f6rg\u00e5sbord\n".getBytes("UTF-8"));
                b.Write("\n".getBytes("UTF-8"));
                b.Write("\u304d\u308c\u3044\n".getBytes("UTF-8"));
                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new GitSharp.Core.RevWalk.RevWalk(db), ((MemoryStream)b.BaseStream).ToArray());
            }

            Assert.AreSame(Constants.CHARSET, c.Encoding);
            Assert.AreEqual("F\u00f6r fattare", c.getAuthorIdent().Name);
            Assert.AreEqual("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
            Assert.AreEqual("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage());
        }
Exemplo n.º 9
0
        public void testParse_implicit_mixed_encoded()
        {
            RevCommit c;

            using (var b = new BinaryWriter(new MemoryStream()))
            {
                b.Write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8"));
                b.Write("author F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("ISO-8859-1"));
                b.Write("committer C O. Miter <*****@*****.**> 1218123390 -0500\n".getBytes("UTF-8"));
                b.Write("\n".getBytes("UTF-8"));
                b.Write("Sm\u00f6rg\u00e5sbord\n".getBytes("UTF-8"));
                b.Write("\n".getBytes("UTF-8"));
                b.Write("\u304d\u308c\u3044\n".getBytes("UTF-8"));

                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new GitSharp.Core.RevWalk.RevWalk(db), ((MemoryStream)b.BaseStream).ToArray());
            }

            Assert.AreSame(Constants.CHARSET, c.Encoding);
            AssertHelper.IgnoreOn(AssertedPlatform.Mono, () => Assert.AreEqual("F\u00f6r fattare", c.getAuthorIdent().Name), "Will fail in mono due to https://bugzilla.novell.com/show_bug.cgi?id=549914");
            Assert.AreEqual("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
            Assert.AreEqual("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage());
        }
Exemplo n.º 10
0
        public void testParse_explicit_bad_encoded2()
        {
            RevCommit c;

            using (var b = new BinaryWriter(new MemoryStream()))
            {
                b.Write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("UTF-8"));
                b.Write("author F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("UTF-8"));
                b.Write("committer C O. Miter <*****@*****.**> 1218123390 -0500\n".getBytes("UTF-8"));
                b.Write("encoding ISO-8859-1\n".getBytes("UTF-8"));
                b.Write("\n".getBytes("UTF-8"));
                b.Write("\u304d\u308c\u3044\n".getBytes("UTF-8"));
                b.Write("\n".getBytes("UTF-8"));
                b.Write("Hi\n".getBytes("UTF-8"));

                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new GitSharp.Core.RevWalk.RevWalk(db), ((MemoryStream)b.BaseStream).ToArray());
            }

            Assert.AreEqual("ISO-8859-1", c.Encoding.WebName.ToUpperInvariant()); //Hacked as Windows uses a lowercased naming convention
            Assert.AreEqual("F\u00f6r fattare", c.getAuthorIdent().Name);
            Assert.AreEqual("\u304d\u308c\u3044", c.getShortMessage());
            Assert.AreEqual("\u304d\u308c\u3044\n\nHi\n", c.getFullMessage());
        }