コード例 #1
0
ファイル: ReflogReaderTest.cs プロジェクト: ashmind/ngit
        public virtual void TestReadTwoLine()
        {
            SetupReflog("logs/refs/heads/master", twoLine);
            ReflogReader reader = new ReflogReader(db, "refs/heads/master");
            IList <ReflogReader.Entry> reverseEntries = reader.GetReverseEntries();

            NUnit.Framework.Assert.AreEqual(2, reverseEntries.Count);
            ReflogReader.Entry e = reverseEntries[0];
            NUnit.Framework.Assert.AreEqual(ObjectId.FromString("c6734895958052a9dbc396cff4459dc1a25029ab"
                                                                ), e.GetOldId());
            NUnit.Framework.Assert.AreEqual(ObjectId.FromString("54794942a18a237c57a80719afed44bb78172b10"
                                                                ), e.GetNewId());
            NUnit.Framework.Assert.AreEqual("Same A U Thor", e.GetWho().GetName());
            NUnit.Framework.Assert.AreEqual("*****@*****.**", e.GetWho().GetEmailAddress
                                                ());
            NUnit.Framework.Assert.AreEqual(60, e.GetWho().GetTimeZoneOffset());
            NUnit.Framework.Assert.AreEqual("2009-05-22T22:36:42", Iso(e.GetWho()));
            NUnit.Framework.Assert.AreEqual("rebase finished: refs/heads/rr/renamebranch5 onto c6e3b9fe2da0293f11eae202ec35fb343191a82d"
                                            , e.GetComment());
            e = reverseEntries[1];
            NUnit.Framework.Assert.AreEqual(ObjectId.FromString("0000000000000000000000000000000000000000"
                                                                ), e.GetOldId());
            NUnit.Framework.Assert.AreEqual(ObjectId.FromString("c6734895958052a9dbc396cff4459dc1a25029ab"
                                                                ), e.GetNewId());
            NUnit.Framework.Assert.AreEqual("A U Thor", e.GetWho().GetName());
            NUnit.Framework.Assert.AreEqual("*****@*****.**", e.GetWho().GetEmailAddress()
                                            );
            NUnit.Framework.Assert.AreEqual(-60, e.GetWho().GetTimeZoneOffset());
            NUnit.Framework.Assert.AreEqual("2009-05-22T20:36:41", Iso(e.GetWho()));
            NUnit.Framework.Assert.AreEqual("branch: Created from rr/renamebranchv4", e.GetComment
                                                ());
        }
コード例 #2
0
ファイル: RefUpdateTest.cs プロジェクト: shoff/ngit
        public virtual void TestUpdateRefDetachedUnbornHead()
        {
            ObjectId ppid = db.Resolve("refs/heads/master^");

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

            updateRef.SetForceUpdate(true);
            updateRef.SetNewObjectId(ppid);
            RefUpdate.Result update = updateRef.Update();
            NUnit.Framework.Assert.AreEqual(RefUpdate.Result.NEW, update);
            NUnit.Framework.Assert.AreEqual(ppid, db.Resolve("HEAD"));
            Ref @ref = db.GetRef("HEAD");

            NUnit.Framework.Assert.AreEqual("HEAD", @ref.GetName());
            NUnit.Framework.Assert.IsTrue([email protected](), "is detached");
            // the branch HEAD referred to is left untouched
            NUnit.Framework.Assert.IsNull(db.Resolve("refs/heads/unborn"));
            ReflogReader reflogReader = new ReflogReader(db, "HEAD");

            ReflogReader.Entry e = reflogReader.GetReverseEntries()[0];
            NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, e.GetOldId());
            NUnit.Framework.Assert.AreEqual(ppid, e.GetNewId());
            NUnit.Framework.Assert.AreEqual("GIT_COMMITTER_EMAIL", e.GetWho().GetEmailAddress
                                                ());
            NUnit.Framework.Assert.AreEqual("GIT_COMMITTER_NAME", e.GetWho().GetName());
            NUnit.Framework.Assert.AreEqual(1250379778000L, e.GetWho().GetWhen().GetTime());
        }
コード例 #3
0
ファイル: RefUpdateTest.cs プロジェクト: shoff/ngit
        public virtual void TestNoCacheObjectIdSubclass()
        {
            string    newRef = "refs/heads/abc";
            RefUpdate ru     = UpdateRef(newRef);

            RefUpdateTest.SubclassedId newid = new RefUpdateTest.SubclassedId(ru.GetNewObjectId
                                                                                  ());
            ru.SetNewObjectId(newid);
            RefUpdate.Result update = ru.Update();
            NUnit.Framework.Assert.AreEqual(RefUpdate.Result.NEW, update);
            Ref r = db.GetAllRefs().Get(newRef);

            NUnit.Framework.Assert.IsNotNull(r);
            NUnit.Framework.Assert.AreEqual(newRef, r.GetName());
            NUnit.Framework.Assert.IsNotNull(r.GetObjectId());
            NUnit.Framework.Assert.AreNotSame(newid, r.GetObjectId());
            NUnit.Framework.Assert.AreSame(typeof(ObjectId), r.GetObjectId().GetType());
            NUnit.Framework.Assert.AreEqual(newid, r.GetObjectId());
            IList <ReflogReader.Entry> reverseEntries1 = db.GetReflogReader("refs/heads/abc").
                                                         GetReverseEntries();

            ReflogReader.Entry entry1 = reverseEntries1[0];
            NUnit.Framework.Assert.AreEqual(1, reverseEntries1.Count);
            NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, entry1.GetOldId());
            NUnit.Framework.Assert.AreEqual(r.GetObjectId(), entry1.GetNewId());
            NUnit.Framework.Assert.AreEqual(new PersonIdent(db).ToString(), entry1.GetWho().ToString
                                                ());
            NUnit.Framework.Assert.AreEqual(string.Empty, entry1.GetComment());
            IList <ReflogReader.Entry> reverseEntries2 = db.GetReflogReader("HEAD").GetReverseEntries
                                                             ();

            NUnit.Framework.Assert.AreEqual(0, reverseEntries2.Count);
        }
コード例 #4
0
        public virtual void TestReadLineWithMissingComment()
        {
            SetupReflog("logs/refs/heads/master", oneLineWithoutComment);
            ReflogReader reader = db.GetReflogReader("master");

            ReflogReader.Entry e = reader.GetLastEntry();
            NUnit.Framework.Assert.AreEqual(ObjectId.FromString("da85355dfc525c9f6f3927b876f379f46ccf826e"
                                                                ), e.GetOldId());
            NUnit.Framework.Assert.AreEqual(ObjectId.FromString("3e7549db262d1e836d9bf0af7e22355468f1717c"
                                                                ), e.GetNewId());
            NUnit.Framework.Assert.AreEqual("A O Thor Too", e.GetWho().GetName());
            NUnit.Framework.Assert.AreEqual("*****@*****.**", e.GetWho().GetEmailAddress());
            NUnit.Framework.Assert.AreEqual(120, e.GetWho().GetTimeZoneOffset());
            NUnit.Framework.Assert.AreEqual("2009-05-22T23:36:40", Iso(e.GetWho()));
            NUnit.Framework.Assert.AreEqual(string.Empty, e.GetComment());
        }
コード例 #5
0
ファイル: ReflogReaderTest.cs プロジェクト: ashmind/ngit
        public virtual void TestReadOneLine()
        {
            SetupReflog("logs/refs/heads/master", oneLine);
            ReflogReader reader = new ReflogReader(db, "refs/heads/master");

            ReflogReader.Entry e = reader.GetLastEntry();
            NUnit.Framework.Assert.AreEqual(ObjectId.FromString("da85355dfc525c9f6f3927b876f379f46ccf826e"
                                                                ), e.GetOldId());
            NUnit.Framework.Assert.AreEqual(ObjectId.FromString("3e7549db262d1e836d9bf0af7e22355468f1717c"
                                                                ), e.GetNewId());
            NUnit.Framework.Assert.AreEqual("A O Thor Too", e.GetWho().GetName());
            NUnit.Framework.Assert.AreEqual("*****@*****.**", e.GetWho().GetEmailAddress());
            NUnit.Framework.Assert.AreEqual(120, e.GetWho().GetTimeZoneOffset());
            NUnit.Framework.Assert.AreEqual("2009-05-22T23:36:40", Iso(e.GetWho()));
            NUnit.Framework.Assert.AreEqual("commit: Add a toString for debugging to RemoteRefUpdate"
                                            , e.GetComment());
        }
コード例 #6
0
ファイル: ReflogReader.cs プロジェクト: ashmind/ngit
        /// <param name="max">max numer of entries to read</param>
        /// <returns>all reflog entries in reverse order</returns>
        /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
        public virtual IList <ReflogReader.Entry> GetReverseEntries(int max)
        {
            byte[] log;
            try
            {
                log = IOUtil.ReadFully(logName);
            }
            catch (FileNotFoundException)
            {
                return(Sharpen.Collections.EmptyList <ReflogReader.Entry>());
            }
            int rs = RawParseUtils.PrevLF(log, log.Length);
            IList <ReflogReader.Entry> ret = new AList <ReflogReader.Entry>();

            while (rs >= 0 && max-- > 0)
            {
                rs = RawParseUtils.PrevLF(log, rs);
                ReflogReader.Entry entry = new ReflogReader.Entry(log, rs < 0 ? 0 : rs + 2);
                ret.AddItem(entry);
            }
            return(ret);
        }
コード例 #7
0
ファイル: ReflogReader.cs プロジェクト: yayanyang/monodevelop
		/// <param name="max">max numer of entries to read</param>
		/// <returns>all reflog entries in reverse order</returns>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public virtual IList<ReflogReader.Entry> GetReverseEntries(int max)
		{
			byte[] log;
			try
			{
				log = IOUtil.ReadFully(logName);
			}
			catch (FileNotFoundException)
			{
				return Sharpen.Collections.EmptyList<ReflogReader.Entry>();
			}
			int rs = RawParseUtils.PrevLF(log, log.Length);
			IList<ReflogReader.Entry> ret = new AList<ReflogReader.Entry>();
			while (rs >= 0 && max-- > 0)
			{
				rs = RawParseUtils.PrevLF(log, rs);
				ReflogReader.Entry entry = new ReflogReader.Entry(log, rs < 0 ? 0 : rs + 2);
				ret.AddItem(entry);
			}
			return ret;
		}