예제 #1
0
        protected RevTree tree(params DirCacheEntry[] entries)
        {
            DirCache        dc = DirCache.newInCore();
            DirCacheBuilder b  = dc.builder();

            foreach (DirCacheEntry e in entries)
            {
                b.add(e);
            }
            b.finish();
            return(rw.lookupTree(dc.writeTree(_ow)));
        }
예제 #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 testParseAllFields()
        {
            ObjectId treeId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67");
            const string name = "v1.2.3.4.5";
            const string taggerName = "A U. Thor";
            const string taggerEmail = "*****@*****.**";
            const int taggerTime = 1218123387;

            var body = new StringBuilder();

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

            body.Append("type tree\n");

            body.Append("tag ");
            body.Append(name);
            body.Append("\n");

            body.Append("tagger ");
            body.Append(taggerName);
            body.Append(" <");
            body.Append(taggerEmail);
            body.Append("> ");
            body.Append(taggerTime);
            body.Append(" +0700\n");

            body.Append("\n");

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

            var c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
            Assert.IsNull(c.getObject());
            Assert.IsNull(c.getTagName());

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

            Assert.IsNotNull(c.getTagName());
            Assert.AreEqual(name, c.getTagName());
            Assert.AreEqual(string.Empty, c.getFullMessage());

            PersonIdent cTagger = c.getTaggerIdent();
            Assert.IsNotNull(cTagger);
            Assert.AreEqual(taggerName, cTagger.Name);
            Assert.AreEqual(taggerEmail, cTagger.EmailAddress);
        }
예제 #4
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);
        }