Ejemplo n.º 1
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 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);
        }
Ejemplo n.º 2
0
        public void testParseOldStyleNoTagger()
        {
            ObjectId treeId  = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67");
            string   name    = "v1.2.3.4.5";
            string   message = "test\n"                                //
                               + "\n"                                  //
                               + "-----BEGIN PGP SIGNATURE-----\n"     //
                               + "Version: GnuPG v1.4.1 (GNU/Linux)\n" //
                               + "\n"                                  //
                               + "iD8DBQBC0b9oF3Y\n"                   //
                               + "-----END PGP SIGNATURE------n";

            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("\n");
            body.Append(message);

            var    rw = new Core.RevWalk.RevWalk(db);
            RevTag c;

            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("test", c.getShortMessage());
            Assert.AreEqual(message, c.getFullMessage());

            Assert.IsNull(c.getTaggerIdent());
        }
Ejemplo n.º 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 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);
        }
Ejemplo n.º 4
0
        public void testParseOldStyleNoTagger()
        {
            ObjectId treeId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67");
            string name = "v1.2.3.4.5";
            string message = "test\n" //
                    + "\n" //
                    + "-----BEGIN PGP SIGNATURE-----\n" //
                    + "Version: GnuPG v1.4.1 (GNU/Linux)\n" //
                    + "\n" //
                    + "iD8DBQBC0b9oF3Y\n" //
                    + "-----END PGP SIGNATURE------n";

            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("\n");
            body.Append(message);

            var rw = new Core.RevWalk.RevWalk(db);
            RevTag c;

            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("test", c.getShortMessage());
            Assert.AreEqual(message, c.getFullMessage());

            Assert.IsNull(c.getTaggerIdent());
        }