Пример #1
0
        public void testUpdateRefDetachedUnbornHead()
        {
            ObjectId ppid = db.Resolve("refs/heads/master^");

            writeSymref("HEAD", "refs/heads/unborn");
            RefUpdate updateRef = db.UpdateRef("HEAD", true);

            updateRef.IsForceUpdate = true;
            updateRef.NewObjectId   = ppid;
            RefUpdate.RefUpdateResult update = updateRef.update();
            Assert.AreEqual(RefUpdate.RefUpdateResult.NEW, update);
            Assert.AreEqual(ppid, db.Resolve("HEAD"));
            Ref @ref = db.getRef("HEAD");

            Assert.AreEqual("HEAD", @ref.Name);
            Assert.IsTrue([email protected](), "is detached");

            // the branch HEAD referred to is left untouched
            Assert.IsNull(db.Resolve("refs/heads/unborn"));
            ReflogReader reflogReader = new ReflogReader(db, "HEAD");

            ReflogReader.Entry e = reflogReader.getReverseEntries()[0];
            Assert.AreEqual(ObjectId.ZeroId, e.getOldId());
            Assert.AreEqual(ppid, e.getNewId());
            Assert.AreEqual("GIT_COMMITTER_EMAIL", e.getWho().EmailAddress);
            Assert.AreEqual("GIT_COMMITTER_NAME", e.getWho().Name);
            Assert.AreEqual(1250379778000L, e.getWho().When);
        }
Пример #2
0
        public void testReadWhileAppendIsInProgress()
        {
            setupReflog("logs/refs/heads/master", twoLineWithAppendInProgress);
            ReflogReader reader         = new ReflogReader(db, "refs/heads/master");
            var          reverseEntries = reader.getReverseEntries();

            Assert.AreEqual(2, reverseEntries.Count);
            ReflogReader.Entry e = reverseEntries[0];

            Assert.AreEqual(ObjectId
                            .FromString("c6734895958052a9dbc396cff4459dc1a25029ab"), e
                            .getOldId());

            Assert.AreEqual(ObjectId
                            .FromString("54794942a18a237c57a80719afed44bb78172b10"), e
                            .getNewId());

            Assert.AreEqual("Same A U Thor", e.getWho().Name);
            Assert.AreEqual("*****@*****.**", e.getWho().EmailAddress);
            Assert.AreEqual(60, e.getWho().TimeZoneOffset);
            Assert.AreEqual("2009-05-22T22:36:42", iso(e.getWho()));
            Assert.AreEqual(
                "rebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d",
                e.getComment());
            // while similar to testReadTwoLine, we can assume that if we get the last entry
            // right, everything else is too
        }
Пример #3
0
        public void testNoCacheObjectIdSubclass()
        {
            string    newRef = "refs/heads/abc";
            RefUpdate ru     = updateRef(newRef);
            RevCommit newid  = new RevCommit(ru.getNewObjectId())
            {
                // empty
            };

            ru.setNewObjectId(newid);
            RefUpdate.RefUpdateResult update = ru.update();
            Assert.AreEqual(RefUpdate.RefUpdateResult.NEW, update);
            Core.Ref r = db.getAllRefs()[newRef];
            Assert.IsNotNull(r);
            Assert.AreEqual(newRef, r.Name);
            Assert.IsNotNull(r.ObjectId);
            Assert.AreNotSame(newid, r.ObjectId);
            Assert.AreSame(typeof(ObjectId), r.ObjectId.GetType());
            Assert.AreEqual(newid.Copy(), r.ObjectId);
            IList <ReflogReader.Entry> reverseEntries1 = db.ReflogReader("refs/heads/abc").getReverseEntries();

            ReflogReader.Entry entry1 = reverseEntries1[0];
            Assert.AreEqual(1, reverseEntries1.Count);
            Assert.AreEqual(ObjectId.ZeroId, entry1.getOldId());
            Assert.AreEqual(r.ObjectId, entry1.getNewId());
            Assert.AreEqual(new PersonIdent(db).ToString(), entry1.getWho().ToString());
            Assert.AreEqual("", entry1.getComment());
            IList <ReflogReader.Entry> reverseEntries2 = db.ReflogReader("HEAD").getReverseEntries();

            Assert.AreEqual(0, reverseEntries2.Count);
        }
Пример #4
0
        public void testReadOneLine()
        {
            setupReflog("logs/refs/heads/master", oneLine);

            ReflogReader reader = new ReflogReader(db, "refs/heads/master");

            ReflogReader.Entry e = reader.getLastEntry();
            Assert.AreEqual(ObjectId
                            .FromString("da85355dfc525c9f6f3927b876f379f46ccf826e"), e
                            .getOldId());
            Assert.AreEqual(ObjectId
                            .FromString("3e7549db262d1e836d9bf0af7e22355468f1717c"), e
                            .getNewId());
            Assert.AreEqual("A O Thor Too", e.getWho().Name);
            Assert.AreEqual("*****@*****.**", e.getWho().EmailAddress);
            Assert.AreEqual(120, e.getWho().TimeZoneOffset);
            Assert.AreEqual("2009-05-22T23:36:40", iso(e.getWho()));
            Assert.AreEqual("commit: Add a toString for debugging to RemoteRefUpdate",
                            e.getComment());
        }
Пример #5
0
        public void testReadTwoLine()
        {
            setupReflog("logs/refs/heads/master", twoLine);

            ReflogReader reader         = new ReflogReader(db, "refs/heads/master");
            var          reverseEntries = reader.getReverseEntries();

            Assert.AreEqual(2, reverseEntries.Count);
            ReflogReader.Entry e = reverseEntries[0];

            Assert.AreEqual(ObjectId
                            .FromString("c6734895958052a9dbc396cff4459dc1a25029ab"), e
                            .getOldId());

            Assert.AreEqual(ObjectId
                            .FromString("54794942a18a237c57a80719afed44bb78172b10"), e
                            .getNewId());

            Assert.AreEqual("Same A U Thor", e.getWho().Name);
            Assert.AreEqual("*****@*****.**", e.getWho().EmailAddress);
            Assert.AreEqual(60, e.getWho().TimeZoneOffset);
            Assert.AreEqual("2009-05-22T22:36:42", iso(e.getWho()));
            Assert.AreEqual(
                "rebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d",
                e.getComment());

            e = reverseEntries[1];
            Assert.AreEqual(ObjectId
                            .FromString("0000000000000000000000000000000000000000"), e
                            .getOldId());

            Assert.AreEqual(ObjectId
                            .FromString("c6734895958052a9dbc396cff4459dc1a25029ab"), e
                            .getNewId());

            Assert.AreEqual("A U Thor", e.getWho().Name);
            Assert.AreEqual("*****@*****.**", e.getWho().EmailAddress);
            Assert.AreEqual(-60, e.getWho().TimeZoneOffset);
            Assert.AreEqual("2009-05-22T20:36:41", iso(e.getWho()));
            Assert.AreEqual("branch: Created from rr/renamebranchv4", e.getComment());
        }