Пример #1
0
        public virtual void Test009_CreateCommitOldFormat()
        {
            ObjectId treeId = InsertTree(new TreeFormatter());

            NGit.CommitBuilder c = new NGit.CommitBuilder();
            c.Author    = new PersonIdent(author, 1154236443000L, -4 * 60);
            c.Committer = new PersonIdent(committer, 1154236443000L, -4 * 60);
            c.Message   = "A Commit\n";
            c.TreeId    = treeId;
            NUnit.Framework.Assert.AreEqual(treeId, c.TreeId);
            ObjectId actid = InsertCommit(c);
            ObjectId cmtid = ObjectId.FromString("9208b2459ea6609a5af68627cc031796d0d9329b");

            NUnit.Framework.Assert.AreEqual(cmtid, actid);
            // Verify the commit we just wrote is in the correct format.
            ObjectDatabase odb = ((ObjectDirectory)db.ObjectDatabase);

            NUnit.Framework.Assert.IsTrue(odb is ObjectDirectory, "is ObjectDirectory");
            XInputStream xis = new XInputStream(new FileInputStream(((ObjectDirectory)odb).FileFor
                                                                        (cmtid)));

            try
            {
                NUnit.Framework.Assert.AreEqual(unchecked ((int)(0x78)), xis.ReadUInt8());
                NUnit.Framework.Assert.AreEqual(unchecked ((int)(0x9c)), xis.ReadUInt8());
                NUnit.Framework.Assert.IsTrue(unchecked ((int)(0x789c)) % 31 == 0);
            }
            finally
            {
                xis.Close();
            }
            // Verify we can read it.
            RevCommit c2 = ParseCommit(actid);

            NUnit.Framework.Assert.IsNotNull(c2);
            NUnit.Framework.Assert.AreEqual(c.Message, c2.GetFullMessage());
            NUnit.Framework.Assert.AreEqual(c.TreeId, c2.Tree);
            NUnit.Framework.Assert.AreEqual(c.Author, c2.GetAuthorIdent());
            NUnit.Framework.Assert.AreEqual(c.Committer, c2.GetCommitterIdent());
        }
Пример #2
0
 public virtual void Test009_CreateCommitOldFormat()
 {
     ObjectId treeId = InsertTree(new TreeFormatter());
     NGit.CommitBuilder c = new NGit.CommitBuilder();
     c.Author = new PersonIdent(author, 1154236443000L, -4 * 60);
     c.Committer = new PersonIdent(committer, 1154236443000L, -4 * 60);
     c.Message = "A Commit\n";
     c.TreeId = treeId;
     NUnit.Framework.Assert.AreEqual(treeId, c.TreeId);
     ObjectId actid = InsertCommit(c);
     ObjectId cmtid = ObjectId.FromString("9208b2459ea6609a5af68627cc031796d0d9329b");
     NUnit.Framework.Assert.AreEqual(cmtid, actid);
     // Verify the commit we just wrote is in the correct format.
     ObjectDatabase odb = ((ObjectDirectory)db.ObjectDatabase);
     NUnit.Framework.Assert.IsTrue(odb is ObjectDirectory, "is ObjectDirectory");
     XInputStream xis = new XInputStream(new FileInputStream(((ObjectDirectory)odb).FileFor
         (cmtid)));
     try
     {
         NUnit.Framework.Assert.AreEqual(unchecked((int)(0x78)), xis.ReadUInt8());
         NUnit.Framework.Assert.AreEqual(unchecked((int)(0x9c)), xis.ReadUInt8());
         NUnit.Framework.Assert.IsTrue(unchecked((int)(0x789c)) % 31 == 0);
     }
     finally
     {
         xis.Close();
     }
     // Verify we can read it.
     RevCommit c2 = ParseCommit(actid);
     NUnit.Framework.Assert.IsNotNull(c2);
     NUnit.Framework.Assert.AreEqual(c.Message, c2.GetFullMessage());
     NUnit.Framework.Assert.AreEqual(c.TreeId, c2.Tree);
     NUnit.Framework.Assert.AreEqual(c.Author, c2.GetAuthorIdent());
     NUnit.Framework.Assert.AreEqual(c.Committer, c2.GetCommitterIdent());
 }