コード例 #1
0
ファイル: PackFileTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestWhole_SmallObject()
        {
            int type = Constants.OBJ_BLOB;

            byte[]  data = GetRng().NextBytes(300);
            RevBlob id   = tr.Blob(data);

            tr.Branch("master").Commit().Add("A", id).Create();
            tr.PackAndPrune();
            NUnit.Framework.Assert.IsTrue(wc.Has(id), "has blob");
            ObjectLoader ol = wc.Open(id);

            NUnit.Framework.Assert.IsNotNull(ol, "created loader");
            NUnit.Framework.Assert.AreEqual(type, ol.GetType());
            NUnit.Framework.Assert.AreEqual(data.Length, ol.GetSize());
            NUnit.Framework.Assert.IsFalse(ol.IsLarge(), "is not large");
            NUnit.Framework.Assert.IsTrue(Arrays.Equals(data, ol.GetCachedBytes()), "same content"
                                          );
            ObjectStream @in = ol.OpenStream();

            NUnit.Framework.Assert.IsNotNull(@in, "have stream");
            NUnit.Framework.Assert.AreEqual(type, @in.GetType());
            NUnit.Framework.Assert.AreEqual(data.Length, @in.GetSize());
            byte[] data2 = new byte[data.Length];
            IOUtil.ReadFully(@in, data2, 0, data.Length);
            NUnit.Framework.Assert.IsTrue(Arrays.Equals(data2, data), "same content");
            NUnit.Framework.Assert.AreEqual(-1, @in.Read(), "stream at EOF");
            @in.Close();
        }
        public virtual void ShouldWorkInNormalCase()
        {
            RevCommit remoteTracking = util.Branch("refs/remotes/origin/master").Commit().Create
                                           ();

            util.Branch("master").Commit().Parent(remoteTracking).Create();
            util.Branch("master").Commit().Create();
            BranchTrackingStatus status = BranchTrackingStatus.Of(util.GetRepository(), "master"
                                                                  );

            NUnit.Framework.Assert.AreEqual(2, status.GetAheadCount());
            NUnit.Framework.Assert.AreEqual(0, status.GetBehindCount());
            NUnit.Framework.Assert.AreEqual("refs/remotes/origin/master", status.GetRemoteTrackingBranch
                                                ());
        }
コード例 #3
0
ファイル: AbbreviationTest.cs プロジェクト: shoff/ngit
        public virtual void TestAbbreviatePackedBlob()
        {
            RevBlob id = test.Blob("test");

            test.Branch("master").Commit().Add("test", id).Child();
            test.PackAndPrune();
            NUnit.Framework.Assert.IsTrue(reader.Has(id));
            NUnit.Framework.Assert.AreEqual(id.Abbreviate(7), reader.Abbreviate(id, 7));
            NUnit.Framework.Assert.AreEqual(id.Abbreviate(8), reader.Abbreviate(id, 8));
            NUnit.Framework.Assert.AreEqual(id.Abbreviate(10), reader.Abbreviate(id, 10));
            NUnit.Framework.Assert.AreEqual(id.Abbreviate(16), reader.Abbreviate(id, 16));
            ICollection <ObjectId> matches = reader.Resolve(reader.Abbreviate(id, 8));

            NUnit.Framework.Assert.IsNotNull(matches);
            NUnit.Framework.Assert.AreEqual(1, matches.Count);
            NUnit.Framework.Assert.AreEqual(id, matches.Iterator().Next());
            NUnit.Framework.Assert.AreEqual(id, db.Resolve(reader.Abbreviate(id, 8).Name));
        }
コード例 #4
0
ファイル: PackWriterTest.cs プロジェクト: ststeiger/ngit-core
        public virtual void TestExclude()
        {
            FileRepository repo = CreateBareRepository();
            TestRepository <FileRepository> testRepo = new TestRepository <FileRepository>(repo
                                                                                           );
            BranchBuilder bb       = testRepo.Branch("refs/heads/master");
            RevBlob       contentA = testRepo.Blob("A");
            RevCommit     c1       = bb.Commit().Add("f", contentA).Create();

            testRepo.GetRevWalk().ParseHeaders(c1);
            PackIndex pf1 = WritePack(repo, Sharpen.Collections.Singleton(c1), Sharpen.Collections
                                      .EmptySet <PackIndex>());

            AssertContent(pf1, Arrays.AsList(c1.Id, c1.Tree.Id, contentA.Id));
            RevBlob   contentB = testRepo.Blob("B");
            RevCommit c2       = bb.Commit().Add("f", contentB).Create();

            testRepo.GetRevWalk().ParseHeaders(c2);
            PackIndex pf2 = WritePack(repo, Sharpen.Collections.Singleton(c2), Sharpen.Collections
                                      .Singleton(pf1));

            AssertContent(pf2, Arrays.AsList(c2.Id, c2.Tree.Id, contentB.Id));
        }
コード例 #5
0
        public virtual void Branch_historyNotPruned()
        {
            RevCommit tip = CommitChain(10);

            tr.Branch("b").Update(tip);
            gc.SetExpireAgeMillis(0);
            gc.Prune(Collections.EmptySet <ObjectId>());
            do
            {
                NUnit.Framework.Assert.IsTrue(repo.HasObject(tip));
                tr.ParseBody(tip);
                RevTree t = tip.Tree;
                NUnit.Framework.Assert.IsTrue(repo.HasObject(t));
                NUnit.Framework.Assert.IsTrue(repo.HasObject(tr.Get(t, "a")));
                tip = tip.ParentCount > 0 ? tip.GetParent(0) : null;
            }while (tip != null);
        }