Exemplo 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 GitSharp.RevWalk.RevWalk(db);

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

            c.parseCanonical(rw, utf8Enc.GetBytes(body.ToString()));
            Assert.IsNotNull(c.getObject());
            Assert.AreEqual(treeId, c.getObject().getId());
            Assert.AreSame(rw.lookupTree(treeId), c.getObject());

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

            PersonIdent cTagger = c.getTaggerIdent();
            Assert.IsNotNull(cTagger);
            Assert.AreEqual(taggerName, cTagger.Name);
            Assert.AreEqual(taggerEmail, cTagger.EmailAddress);
        }
Exemplo n.º 2
0
        private void testOneType(int typeCode)
        {
            ObjectId locId = Id("9788669ad918b6fcce64af8882fc9a81cb6aba67");
            var b = new StringBuilder();
            b.Append("object " + locId.Name + "\n");
            b.Append("type " + Constants.typeString(typeCode) + "\n");
            b.Append("tag v1.2.3.4.5\n");
            b.Append("tagger A U. Thor <*****@*****.**> 1218123387 +0700\n");
            b.Append("\n");

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

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

            c.parseCanonical(rw, utf8Enc.GetBytes(b.ToString()));
            Assert.IsNotNull(c.getObject());
            Assert.AreEqual(locId, c.getObject().getId());
            Assert.AreSame(rw.lookupAny(locId, typeCode), c.getObject());
        }
Exemplo n.º 3
0
        public void testParse_implicit_UTF8_encoded()
        {
            RevTag c;
            using (var b = new BinaryWriter(new MemoryStream()))
            {
                b.Write(utf8Enc.GetBytes("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"));
                b.Write(utf8Enc.GetBytes("type tree\n"));
                b.Write(utf8Enc.GetBytes("tag v1.2.3.4.5\n"));
                b.Write(utf8Enc.GetBytes("tagger F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n"));
                b.Write(utf8Enc.GetBytes("\n"));
                b.Write(utf8Enc.GetBytes("Sm\u00f6rg\u00e5sbord\n"));
                b.Write(utf8Enc.GetBytes("\n"));
                b.Write(utf8Enc.GetBytes("\u304d\u308c\u3044\n"));

                c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
                c.parseCanonical(new GitSharp.RevWalk.RevWalk(db), ((MemoryStream) b.BaseStream).ToArray());
            }
            Assert.AreEqual("F\u00f6r fattare", c.getTaggerIdent().Name);
            Assert.AreEqual("Sm\u00f6rg\u00e5sbord", c.getShortMessage());
            Assert.AreEqual("Sm\u00f6rg\u00e5sbord\n\n\u304d\u308c\u3044\n", c.getFullMessage());
        }
Exemplo n.º 4
0
        private RevTag create(string msg)
        {
            var b = new StringBuilder();
            b.Append("object 9788669ad918b6fcce64af8882fc9a81cb6aba67\n");
            b.Append("type tree\n");
            b.Append("tag v1.2.3.4.5\n");
            b.Append("tagger A U. Thor <*****@*****.**> 1218123387 +0700\n");
            b.Append("\n");
            b.Append(msg);

            var c = new RevTag(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));

            c.parseCanonical(new GitSharp.RevWalk.RevWalk(db), utf8Enc.GetBytes(b.ToString()));
            return c;
        }
Exemplo n.º 5
0
 private void advertiseTag(RevTag tag, string refName)
 {
     RevObject o = tag;
     do
     {
         RevObject target = ((RevTag)o).getObject();
         try
         {
             _walk.parseHeaders(target);
         }
         catch (IOException)
         {
             return;
         }
         target.add(ADVERTISED);
         o = target;
     } while (o is RevTag);
     advertiseAny(tag.getObject(), refName);
 }