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 ()); }
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"); ReflogEntry 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()); }
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()); }
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()); }
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)); }
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()); }
public virtual void RefLogIncludesCommitMessage() { PersonIdent who = new PersonIdent("user", "*****@*****.**"); DeleteTrashFile("file.txt"); RevCommit stashed = git.StashCreate().SetPerson(who).Call(); NUnit.Framework.Assert.IsNotNull(stashed); NUnit.Framework.Assert.AreEqual("content", Read(committedFile)); ValidateStashedCommit(stashed); ReflogReader reader = new ReflogReader(git.GetRepository(), Constants.R_STASH); ReflogEntry entry = reader.GetLastEntry(); NUnit.Framework.Assert.IsNotNull(entry); NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, entry.GetOldId()); NUnit.Framework.Assert.AreEqual(stashed, entry.GetNewId()); NUnit.Framework.Assert.AreEqual(who, entry.GetWho()); NUnit.Framework.Assert.AreEqual(stashed.GetFullMessage(), entry.GetComment()); }
public virtual void DropBoundaryStashedCommits() { Write(committedFile, "content2"); Ref stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNull(stashRef); RevCommit firstStash = git.StashCreate().Call(); NUnit.Framework.Assert.IsNotNull(firstStash); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNotNull(stashRef); NUnit.Framework.Assert.AreEqual(firstStash, git.GetRepository().GetRef(Constants. R_STASH).GetObjectId()); Write(committedFile, "content3"); RevCommit secondStash = git.StashCreate().Call(); NUnit.Framework.Assert.IsNotNull(secondStash); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNotNull(stashRef); NUnit.Framework.Assert.AreEqual(secondStash, git.GetRepository().GetRef(Constants .R_STASH).GetObjectId()); Write(committedFile, "content4"); RevCommit thirdStash = git.StashCreate().Call(); NUnit.Framework.Assert.IsNotNull(thirdStash); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNotNull(stashRef); NUnit.Framework.Assert.AreEqual(thirdStash, git.GetRepository().GetRef(Constants. R_STASH).GetObjectId()); Write(committedFile, "content5"); RevCommit fourthStash = git.StashCreate().Call(); NUnit.Framework.Assert.IsNotNull(fourthStash); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNotNull(stashRef); NUnit.Framework.Assert.AreEqual(fourthStash, git.GetRepository().GetRef(Constants .R_STASH).GetObjectId()); NUnit.Framework.Assert.AreEqual(thirdStash, git.StashDrop().Call()); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNotNull(stashRef); NUnit.Framework.Assert.AreEqual(thirdStash, stashRef.GetObjectId()); NUnit.Framework.Assert.AreEqual(thirdStash, git.StashDrop().SetStashRef(2).Call() ); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNotNull(stashRef); NUnit.Framework.Assert.AreEqual(thirdStash, stashRef.GetObjectId()); ReflogReader reader = new ReflogReader(git.GetRepository(), Constants.R_STASH); IList<ReflogEntry> entries = reader.GetReverseEntries(); NUnit.Framework.Assert.AreEqual(2, entries.Count); NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, entries[1].GetOldId()); NUnit.Framework.Assert.AreEqual(secondStash, entries[1].GetNewId()); NUnit.Framework.Assert.IsTrue(entries[1].GetComment().Length > 0); NUnit.Framework.Assert.AreEqual(entries[0].GetOldId(), entries[1].GetNewId()); NUnit.Framework.Assert.AreEqual(thirdStash, entries[0].GetNewId()); NUnit.Framework.Assert.IsTrue(entries[0].GetComment().Length > 0); }
public virtual void DropAll() { Write(committedFile, "content2"); Ref stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNull(stashRef); RevCommit firstStash = git.StashCreate().Call(); NUnit.Framework.Assert.IsNotNull(firstStash); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNotNull(stashRef); NUnit.Framework.Assert.AreEqual(firstStash, git.GetRepository().GetRef(Constants. R_STASH).GetObjectId()); Write(committedFile, "content3"); RevCommit secondStash = git.StashCreate().Call(); NUnit.Framework.Assert.IsNotNull(secondStash); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNotNull(stashRef); NUnit.Framework.Assert.AreEqual(secondStash, git.GetRepository().GetRef(Constants .R_STASH).GetObjectId()); NUnit.Framework.Assert.IsNull(git.StashDrop().SetAll(true).Call()); NUnit.Framework.Assert.IsNull(git.GetRepository().GetRef(Constants.R_STASH)); ReflogReader reader = new ReflogReader(git.GetRepository(), Constants.R_STASH); NUnit.Framework.Assert.IsTrue(reader.GetReverseEntries().IsEmpty()); }
public virtual void DropSingleStashedCommit() { Write(committedFile, "content2"); Ref stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNull(stashRef); RevCommit stashed = git.StashCreate().Call(); NUnit.Framework.Assert.IsNotNull(stashed); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.AreEqual(stashed, git.GetRepository().GetRef(Constants.R_STASH ).GetObjectId()); NUnit.Framework.Assert.IsNull(git.StashDrop().Call()); stashRef = git.GetRepository().GetRef(Constants.R_STASH); NUnit.Framework.Assert.IsNull(stashRef); ReflogReader reader = new ReflogReader(git.GetRepository(), Constants.R_STASH); NUnit.Framework.Assert.IsTrue(reader.GetReverseEntries().IsEmpty()); }