public virtual void TestSpecificEntryNumber()
        {
            SetupReflog("logs/refs/heads/master", twoLine);
            ReflogReader reader = new ReflogReader(db, "refs/heads/master");
            ReflogEntry  e      = reader.GetReverseEntry(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 = reader.GetReverseEntry(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
                                                ());
            NUnit.Framework.Assert.IsNull(reader.GetReverseEntry(3));
        }
예제 #2
0
        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 <ReflogEntry> reverseEntries1 = db.GetReflogReader("refs/heads/abc").GetReverseEntries
                                                      ();
            ReflogEntry 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 <ReflogEntry> reverseEntries2 = db.GetReflogReader("HEAD").GetReverseEntries
                                                      ();

            NUnit.Framework.Assert.AreEqual(0, reverseEntries2.Count);
        }
예제 #3
0
		internal CheckoutEntry(ReflogEntry reflogEntry)
		{
			string comment = reflogEntry.GetComment();
			int p1 = CHECKOUT_MOVING_FROM.Length;
			int p2 = comment.IndexOf(" to ", p1);
			int p3 = comment.Length;
			from = Sharpen.Runtime.Substring(comment, p1, p2);
			to = Sharpen.Runtime.Substring(comment, p2 + " to ".Length, p3);
		}
예제 #4
0
        internal CheckoutEntry(ReflogEntry reflogEntry)
        {
            string comment = reflogEntry.GetComment();
            int    p1      = CHECKOUT_MOVING_FROM.Length;
            int    p2      = comment.IndexOf(" to ", p1);
            int    p3      = comment.Length;

            from = Sharpen.Runtime.Substring(comment, p1, p2);
            to   = Sharpen.Runtime.Substring(comment, p2 + " to ".Length, p3);
        }
        public virtual void TestReadLineWithMissingComment()
        {
            SetupReflog("logs/refs/heads/master", oneLineWithoutComment);
            ReflogReader reader = db.GetReflogReader("master");
            ReflogEntry  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());
        }
        public virtual void TestReadOneLine()
        {
            SetupReflog("logs/refs/heads/master", oneLine);
            ReflogReader reader = new ReflogReader(db, "refs/heads/master");
            ReflogEntry  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());
        }
        public virtual void TestReadWhileAppendIsInProgress()
        {
            SetupReflog("logs/refs/heads/master", twoLineWithAppendInProgress);
            ReflogReader        reader         = new ReflogReader(db, "refs/heads/master");
            IList <ReflogEntry> reverseEntries = reader.GetReverseEntries();

            NUnit.Framework.Assert.AreEqual(2, reverseEntries.Count);
            ReflogEntry 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());
        }
예제 #8
0
 /// <summary>
 /// Write the given
 /// <see cref="ReflogEntry">ReflogEntry</see>
 /// entry to the ref's log
 /// </summary>
 /// <param name="refName"></param>
 /// <param name="entry"></param>
 /// <returns>this writer</returns>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 public virtual NGit.Storage.File.ReflogWriter Log(string refName, ReflogEntry entry
                                                   )
 {
     return(Log(refName, entry.GetOldId(), entry.GetNewId(), entry.GetWho(), entry.GetComment
                    ()));
 }
예제 #9
0
		/// <summary>
		/// Write the given
		/// <see cref="ReflogEntry">ReflogEntry</see>
		/// entry to the ref's log
		/// </summary>
		/// <param name="refName"></param>
		/// <param name="entry"></param>
		/// <returns>this writer</returns>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		public virtual NGit.Storage.File.ReflogWriter Log(string refName, ReflogEntry entry
			)
		{
			return Log(refName, entry.GetOldId(), entry.GetNewId(), entry.GetWho(), entry.GetComment
				());
		}