getAuthorIdent() 공개 메소드

Parse the author identity from the raw buffer. This method parses and returns the content of the author line, after taking the commit's character set into account and decoding the author name and email address. This method is fairly expensive and produces a new PersonIdent instance on each invocation. Callers should invoke this method only if they are certain they will be outputting the result, and should cache the return value for as long as necessary to use all information from it. RevFilter implementations should try to use RawParseUtils to scan the RawBuffer instead, as this will allow faster evaluation of commits.
public getAuthorIdent ( ) : PersonIdent
리턴 PersonIdent
예제 #1
0
        public void testParse_explicit_bad_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("encoding EUC-JP\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("EUC-JP", c.Encoding.WebName.ToUpperInvariant()); //Hacked as Windows uses a lowercased naming convention
            Assert.AreEqual("F\u00f6r fattare", c.getAuthorIdent().Name,"Will fail in mono due to https://bugzilla.novell.com/show_bug.cgi?id=547902");
            Assert.AreEqual("\u304d\u308c\u3044", c.getShortMessage());
            Assert.AreEqual("\u304d\u308c\u3044\n\nHi\n", c.getFullMessage());
        }
예제 #2
0
        public void testParse_NoParents()
        {
            ObjectId treeId = id("9788669ad918b6fcce64af8882fc9a81cb6aba67");
            const string authorName = "A U. Thor";
            const string authorEmail = "*****@*****.**";
            const int authorTime = 1218123387;

            const string committerName = "C O. Miter";
            const string committerEmail = "*****@*****.**";
            const int committerTime = 1218123390;
            var body = new StringBuilder();

            body.Append("tree ");
            body.Append(treeId.Name);
            body.Append("\n");

            body.Append("author ");
            body.Append(authorName);
            body.Append(" <");
            body.Append(authorEmail);
            body.Append("> ");
            body.Append(authorTime);
            body.Append(" +0700\n");

            body.Append("committer ");
            body.Append(committerName);
            body.Append(" <");
            body.Append(committerEmail);
            body.Append("> ");
            body.Append(committerTime);
            body.Append(" -0500\n");

            body.Append("\n");

            var rw = new GitSharp.Core.RevWalk.RevWalk(db);

            var c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
            Assert.IsNull(c.Tree);
            Assert.IsNull(c.Parents);

            c.parseCanonical(rw, body.ToString().getBytes("UTF-8"));
            Assert.IsNotNull(c.Tree);
            Assert.AreEqual(treeId, c.Tree.getId());
            Assert.AreSame(rw.lookupTree(treeId), c.Tree);

            Assert.IsNotNull(c.Parents);
            Assert.AreEqual(0, c.Parents.Length);
            Assert.AreEqual(string.Empty, c.getFullMessage());

            PersonIdent cAuthor = c.getAuthorIdent();
            Assert.IsNotNull(cAuthor);
            Assert.AreEqual(authorName, cAuthor.Name);
            Assert.AreEqual(authorEmail, cAuthor.EmailAddress);

            PersonIdent cCommitter = c.getCommitterIdent();
            Assert.IsNotNull(cCommitter);
            Assert.AreEqual(committerName, cCommitter.Name);
            Assert.AreEqual(committerEmail, cCommitter.EmailAddress);
        }
예제 #3
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());
        }
예제 #4
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());
        }
예제 #5
0
        public void testParse_explicit_encoded()
        {
            Assert.Ignore("We are going to deal with encoding problems later. For now, they are only disturbing the build.");
            RevCommit c;
            using (var b = new BinaryWriter(new MemoryStream()))
            {
                b.Write("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n".getBytes("EUC-JP"));
                b.Write("author F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n".getBytes("EUC-JP"));
                b.Write("committer C O. Miter <*****@*****.**> 1218123390 -0500\n".getBytes("EUC-JP"));
                b.Write("encoding euc_JP\n".getBytes("EUC-JP"));
                b.Write("\n".getBytes("EUC-JP"));
                b.Write("\u304d\u308c\u3044\n".getBytes("EUC-JP"));
                b.Write("\n".getBytes("EUC-JP"));
                b.Write("Hi\n".getBytes("EUC-JP"));

                c = new RevCommit(id("9473095c4cb2f12aefe1db8a355fe3fafba42f67")); // bogus id
                c.parseCanonical(new GitSharp.Core.RevWalk.RevWalk(db), ((MemoryStream) b.BaseStream).ToArray());
            }
            Assert.AreEqual("EUC-JP", 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());
        }