Пример #1
0
        public void testParse_explicit_bad_encoded()
        {
            RevCommit c;
            using (var b = new BinaryWriter(new MemoryStream()))
            {
                b.Write(_utf8Enc.GetBytes("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"));
                b.Write(_isoEnc.GetBytes("author F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n"));
                b.Write(_utf8Enc.GetBytes("committer C O. Miter <*****@*****.**> 1218123390 -0500\n"));
                b.Write(_utf8Enc.GetBytes("encoding EUC-JP\n"));
                b.Write(_utf8Enc.GetBytes("\n"));
                b.Write(_utf8Enc.GetBytes("\u304d\u308c\u3044\n"));
                b.Write(_utf8Enc.GetBytes("\n"));
                b.Write(_utf8Enc.GetBytes("Hi\n"));

                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new GitSharp.RevWalk.RevWalk(db), ((MemoryStream) b.BaseStream).ToArray());
            }
            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());
        }
Пример #2
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.RevWalk.RevWalk(db), _utf8Enc.GetBytes(b.ToString()));

            Assert.AreEqual(string.Empty, c.getFullMessage());
            Assert.AreEqual(string.Empty, c.getShortMessage());
        }