Ejemplo n.º 1
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());
        }
Ejemplo n.º 2
0
        public virtual void DropFirstStashedCommit()
        {
            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.AreEqual(firstStash, git.StashDrop().Call());
            stashRef = git.GetRepository().GetRef(Constants.R_STASH);
            NUnit.Framework.Assert.IsNotNull(stashRef);
            NUnit.Framework.Assert.AreEqual(firstStash, stashRef.GetObjectId());
            ReflogReader        reader  = new ReflogReader(git.GetRepository(), Constants.R_STASH);
            IList <ReflogEntry> entries = reader.GetReverseEntries();

            NUnit.Framework.Assert.AreEqual(1, entries.Count);
            NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, entries[0].GetOldId());
            NUnit.Framework.Assert.AreEqual(firstStash, entries[0].GetNewId());
            NUnit.Framework.Assert.IsTrue(entries[0].GetComment().Length > 0);
        }
Ejemplo n.º 3
0
        /// <exception cref="System.Exception"></exception>
        private void DoCherryPickAndCheckResult(Git git, RevCommit sideCommit, ResolveMerger.MergeFailureReason
                                                reason)
        {
            // get current index state
            string indexState = IndexState(CONTENT);
            // cherry-pick
            CherryPickResult result = git.CherryPick().Include(sideCommit.Id).Call();

            NUnit.Framework.Assert.AreEqual(CherryPickResult.CherryPickStatus.FAILED, result.
                                            GetStatus());
            // staged file a causes DIRTY_INDEX
            NUnit.Framework.Assert.AreEqual(1, result.GetFailingPaths().Count);
            NUnit.Framework.Assert.AreEqual(reason, result.GetFailingPaths().Get("a"));
            NUnit.Framework.Assert.AreEqual("a(modified)", Read(new FilePath(db.WorkTree, "a"
                                                                             )));
            // index shall be unchanged
            NUnit.Framework.Assert.AreEqual(indexState, IndexState(CONTENT));
            NUnit.Framework.Assert.AreEqual(RepositoryState.SAFE, db.GetRepositoryState());
            if (reason == null)
            {
                ReflogReader reader = db.GetReflogReader(Constants.HEAD);
                NUnit.Framework.Assert.IsTrue(reader.GetLastEntry().GetComment().StartsWith("cherry-pick: "
                                                                                            ));
                reader = db.GetReflogReader(db.GetBranch());
                NUnit.Framework.Assert.IsTrue(reader.GetLastEntry().GetComment().StartsWith("cherry-pick: "
                                                                                            ));
            }
        }
Ejemplo n.º 4
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
        }
Ejemplo n.º 5
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);
        }
 /// <summary>Run the reflog command</summary>
 /// <exception cref="NGit.Api.Errors.GitAPIException">NGit.Api.Errors.GitAPIException
 ///     </exception>
 /// <exception cref="NGit.Api.Errors.InvalidRefNameException">NGit.Api.Errors.InvalidRefNameException
 ///     </exception>
 public override ICollection <ReflogEntry> Call()
 {
     CheckCallable();
     try
     {
         ReflogReader reader = new ReflogReader(repo, @ref);
         return(reader.GetReverseEntries());
     }
     catch (IOException e)
     {
         throw new InvalidRefNameException(MessageFormat.Format(JGitText.Get().cannotRead,
                                                                @ref), e);
     }
 }
Ejemplo n.º 7
0
        public virtual void TestRevert()
        {
            Git git = new Git(db);

            WriteTrashFile("a", "first line\nsec. line\nthird line\n");
            git.Add().AddFilepattern("a").Call();
            git.Commit().SetMessage("create a").Call();
            WriteTrashFile("b", "content\n");
            git.Add().AddFilepattern("b").Call();
            git.Commit().SetMessage("create b").Call();
            WriteTrashFile("a", "first line\nsec. line\nthird line\nfourth line\n");
            git.Add().AddFilepattern("a").Call();
            git.Commit().SetMessage("enlarged a").Call();
            WriteTrashFile("a", "first line\nsecond line\nthird line\nfourth line\n");
            git.Add().AddFilepattern("a").Call();
            RevCommit fixingA = git.Commit().SetMessage("fixed a").Call();

            WriteTrashFile("b", "first line\n");
            git.Add().AddFilepattern("b").Call();
            git.Commit().SetMessage("fixed b").Call();
            git.Revert().Include(fixingA).Call();
            NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "b").Exists());
            CheckFile(new FilePath(db.WorkTree, "a"), "first line\nsec. line\nthird line\nfourth line\n"
                      );
            Iterator <RevCommit> history      = git.Log().Call().Iterator();
            RevCommit            revertCommit = history.Next();
            string expectedMessage            = "Revert \"fixed a\"\n\n" + "This reverts commit " + fixingA
                                                .Id.GetName() + ".\n";

            NUnit.Framework.Assert.AreEqual(expectedMessage, revertCommit.GetFullMessage());
            NUnit.Framework.Assert.AreEqual("fixed b", history.Next().GetFullMessage());
            NUnit.Framework.Assert.AreEqual("fixed a", history.Next().GetFullMessage());
            NUnit.Framework.Assert.AreEqual("enlarged a", history.Next().GetFullMessage());
            NUnit.Framework.Assert.AreEqual("create b", history.Next().GetFullMessage());
            NUnit.Framework.Assert.AreEqual("create a", history.Next().GetFullMessage());
            NUnit.Framework.Assert.IsFalse(history.HasNext());
            ReflogReader reader = db.GetReflogReader(Constants.HEAD);

            NUnit.Framework.Assert.IsTrue(reader.GetLastEntry().GetComment().StartsWith("revert: Revert \""
                                                                                        ));
            reader = db.GetReflogReader(db.GetBranch());
            NUnit.Framework.Assert.IsTrue(reader.GetLastEntry().GetComment().StartsWith("revert: Revert \""
                                                                                        ));
        }
Ejemplo n.º 8
0
        public DateTime?GetLastLocalCommitDate(RepositoryConnectionInfo repInfo)
        {
            var git        = Git.Open(repInfo.LocalDirectory);
            var repository = git.GetRepository();

            var reader  = new ReflogReader(repository, "HEAD");
            var lastRef = reader.GetLastEntry();

            if (lastRef == null)
            {
                return(null);
            }

            var authorIdent    = lastRef.GetWho();
            var authorDate     = authorIdent.GetWhen();
            var timeZoneOffset = TimeSpan.FromMinutes(authorIdent.GetTimeZoneOffset());

            return(authorDate + timeZoneOffset);
        }
        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());
        }
Ejemplo n.º 10
0
        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());
        }
Ejemplo n.º 11
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());
        }
Ejemplo n.º 12
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());
        }
Ejemplo n.º 13
0
        public virtual void TestCommitAmend()
        {
            Git git = new Git(db);

            git.Commit().SetMessage("first comit").Call();
            // typo
            git.Commit().SetAmend(true).SetMessage("first commit").Call();
            Iterable <RevCommit> commits = git.Log().Call();
            int c = 0;

            foreach (RevCommit commit in commits)
            {
                NUnit.Framework.Assert.AreEqual("first commit", commit.GetFullMessage());
                c++;
            }
            NUnit.Framework.Assert.AreEqual(1, c);
            ReflogReader reader = db.GetReflogReader(Constants.HEAD);

            NUnit.Framework.Assert.IsTrue(reader.GetLastEntry().GetComment().StartsWith("commit (amend):"
                                                                                        ));
        }
Ejemplo n.º 14
0
        public virtual void TestSomeCommits()
        {
            // do 4 commits
            Git git = new Git(db);

            git.Commit().SetMessage("initial commit").Call();
            git.Commit().SetMessage("second commit").SetCommitter(committer).Call();
            git.Commit().SetMessage("third commit").SetAuthor(author).Call();
            git.Commit().SetMessage("fourth commit").SetAuthor(author).SetCommitter(committer
                                                                                    ).Call();
            Iterable <RevCommit> commits = git.Log().Call();
            // check that all commits came in correctly
            PersonIdent defaultCommitter = new PersonIdent(db);

            PersonIdent[] expectedAuthors = new PersonIdent[] { defaultCommitter, committer,
                                                                author, author };
            PersonIdent[] expectedCommitters = new PersonIdent[] { defaultCommitter, committer
                                                                   , defaultCommitter, committer };
            string[] expectedMessages = new string[] { "initial commit", "second commit", "third commit"
                                                       , "fourth commit" };
            int l = expectedAuthors.Length - 1;

            foreach (RevCommit c in commits)
            {
                NUnit.Framework.Assert.AreEqual(expectedAuthors[l].GetName(), c.GetAuthorIdent().
                                                GetName());
                NUnit.Framework.Assert.AreEqual(expectedCommitters[l].GetName(), c.GetCommitterIdent
                                                    ().GetName());
                NUnit.Framework.Assert.AreEqual(c.GetFullMessage(), expectedMessages[l]);
                l--;
            }
            NUnit.Framework.Assert.AreEqual(l, -1);
            ReflogReader reader = db.GetReflogReader(Constants.HEAD);

            NUnit.Framework.Assert.IsTrue(reader.GetLastEntry().GetComment().StartsWith("commit:"
                                                                                        ));
            reader = db.GetReflogReader(db.GetBranch());
            NUnit.Framework.Assert.IsTrue(reader.GetLastEntry().GetComment().StartsWith("commit:"
                                                                                        ));
        }
Ejemplo n.º 15
0
        public void testUpdateRefDetached()
        {
            ObjectId pid = db.Resolve("refs/heads/master");
            ObjectId ppid = db.Resolve("refs/heads/master^");
            RefUpdate updateRef = db.UpdateRef("HEAD", true);
            updateRef.IsForceUpdate = true;
            updateRef.NewObjectId = ppid;
            RefUpdate.RefUpdateResult update = updateRef.Update();
            Assert.AreEqual(RefUpdate.RefUpdateResult.Forced, update);
            Assert.AreEqual(ppid, db.Resolve("HEAD"));
            Ref @ref = db.getRef("HEAD");
            Assert.AreEqual("HEAD", @ref.Name);
            Assert.AreEqual("HEAD", @ref.OriginalName);

            // the branch HEAD referred to is left untouched
            Assert.AreEqual(pid, db.Resolve("refs/heads/master"));
            ReflogReader reflogReader = new ReflogReader(db, "HEAD");
            ReflogReader.Entry e = reflogReader.getReverseEntries()[0];
            Assert.AreEqual(pid, 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);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Drop the configured entry from the stash reflog and return value of the
        /// stash reference after the drop occurs
        /// </summary>
        /// <returns>commit id of stash reference or null if no more stashed changes</returns>
        /// <exception cref="NGit.Api.Errors.GitAPIException">NGit.Api.Errors.GitAPIException
        ///     </exception>
        public override ObjectId Call()
        {
            CheckCallable();
            Ref stashRef = GetRef();

            if (stashRef == null)
            {
                return(null);
            }
            if (all)
            {
                DeleteRef(stashRef);
                return(null);
            }
            ReflogReader        reader = new ReflogReader(repo, Constants.R_STASH);
            IList <ReflogEntry> entries;

            try
            {
                entries = reader.GetReverseEntries();
            }
            catch (IOException e)
            {
                throw new JGitInternalException(JGitText.Get().stashDropFailed, e);
            }
            if (stashRefEntry >= entries.Count)
            {
                throw new JGitInternalException(JGitText.Get().stashDropMissingReflog);
            }
            if (entries.Count == 1)
            {
                DeleteRef(stashRef);
                return(null);
            }
            ReflogWriter writer        = new ReflogWriter(repo, true);
            string       stashLockRef  = ReflogWriter.RefLockFor(Constants.R_STASH);
            FilePath     stashLockFile = writer.LogFor(stashLockRef);
            FilePath     stashFile     = writer.LogFor(Constants.R_STASH);

            if (stashLockFile.Exists())
            {
                throw new JGitInternalException(JGitText.Get().stashDropFailed, new LockFailedException
                                                    (stashFile));
            }
            entries.Remove(stashRefEntry);
            ObjectId entryId = ObjectId.ZeroId;

            try
            {
                for (int i = entries.Count - 1; i >= 0; i--)
                {
                    ReflogEntry entry = entries[i];
                    writer.Log(stashLockRef, entryId, entry.GetNewId(), entry.GetWho(), entry.GetComment
                                   ());
                    entryId = entry.GetNewId();
                }
                if (!stashLockFile.RenameTo(stashFile))
                {
                    FileUtils.Delete(stashFile);
                    if (!stashLockFile.RenameTo(stashFile))
                    {
                        throw new JGitInternalException(MessageFormat.Format(JGitText.Get().couldNotWriteFile
                                                                             , stashLockFile.GetPath(), stashFile.GetPath()));
                    }
                }
            }
            catch (IOException e)
            {
                throw new JGitInternalException(JGitText.Get().stashDropFailed, e);
            }
            UpdateRef(stashRef, entryId);
            try
            {
                Ref newStashRef = repo.GetRef(Constants.R_STASH);
                return(newStashRef != null?newStashRef.GetObjectId() : null);
            }
            catch (IOException e)
            {
                throw new InvalidRefNameException(MessageFormat.Format(JGitText.Get().cannotRead,
                                                                       Constants.R_STASH), e);
            }
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
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());
        }
Ejemplo n.º 19
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
        }
Ejemplo n.º 20
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());
        }