当前位置: 首页>>代码示例>>C#>>正文


C# TestRepository.Commit方法代码示例

本文整理汇总了C#中TestRepository.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# TestRepository.Commit方法的具体用法?C# TestRepository.Commit怎么用?C# TestRepository.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestRepository的用法示例。


在下文中一共展示了TestRepository.Commit方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetUp

 public override void SetUp()
 {
     base.SetUp();
     diskRepo = CreateBareRepository();
     refdir = (RefDirectory)diskRepo.RefDatabase;
     repo = new TestRepository<Repository>(diskRepo);
     A = repo.Commit().Create();
     B = repo.Commit(repo.GetRevWalk().ParseCommit(A));
     v1_0 = repo.Tag("v1_0", B);
     repo.GetRevWalk().ParseBody(v1_0);
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:11,代码来源:RefDirectoryTest.cs

示例2: SetUp

		public override void SetUp()
		{
			base.SetUp();
			src = CreateBareRepository();
			dst = CreateBareRepository();
			// Fill dst with a some common history.
			//
			TestRepository d = new TestRepository<Repository>(dst);
			a = d.Blob("a");
			A = d.Commit(d.Tree(d.File("a", a)));
			B = d.Commit().Parent(A).Create();
			d.Update(R_MASTER, B);
			// Clone from dst into src
			//
			NGit.Transport.Transport t = NGit.Transport.Transport.Open(src, UriOf(dst));
			try
			{
				t.Fetch(PM, Collections.Singleton(new RefSpec("+refs/*:refs/*")));
				NUnit.Framework.Assert.AreEqual(B, src.Resolve(R_MASTER));
			}
			finally
			{
				t.Close();
			}
			// Now put private stuff into dst.
			//
			b = d.Blob("b");
			P = d.Commit(d.Tree(d.File("b", b)), A);
			d.Update(R_PRIVATE, P);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:30,代码来源:ReceivePackAdvertiseRefsHookTest.cs

示例3: TestUsingUnknownTreeFails

		public virtual void TestUsingUnknownTreeFails()
		{
			TestRepository<Repository> s = new TestRepository<Repository>(src);
			RevCommit N = s.Commit().Parent(B).Add("q", s.Blob("a")).Create();
			RevTree t = s.ParseBody(N).Tree;
			// Don't include the tree in the pack.
			//
			TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
			PackHeader(pack, 1);
			Copy(pack, src.Open(N));
			Digest(pack);
			TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
			PacketLineOut inPckLine = new PacketLineOut(inBuf);
			inPckLine.WriteString(ObjectId.ZeroId.Name + ' ' + N.Name + ' ' + "refs/heads/s" 
				+ '\0' + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
			inPckLine.End();
			pack.WriteTo(inBuf, PM);
			TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
			ReceivePack rp = new ReceivePack(dst);
			rp.SetCheckReceivedObjects(true);
			rp.SetCheckReferencedObjectsAreReachable(true);
			rp.SetAdvertiseRefsHook(new ReceivePackAdvertiseRefsHookTest.HidePrivateHook());
			try
			{
				Receive(rp, inBuf, outBuf);
				NUnit.Framework.Assert.Fail("Expected UnpackException");
			}
			catch (UnpackException failed)
			{
				Exception err = failed.InnerException;
				NUnit.Framework.Assert.IsTrue(err is MissingObjectException);
				MissingObjectException moe = (MissingObjectException)err;
				NUnit.Framework.Assert.AreEqual(t, moe.GetObjectId());
			}
			PacketLineIn r = AsPacketLineIn(outBuf);
			string master = r.ReadString();
			int nul = master.IndexOf('\0');
			NUnit.Framework.Assert.IsTrue(nul > 0, "has capability list");
			NUnit.Framework.Assert.AreEqual(B.Name + ' ' + R_MASTER, Sharpen.Runtime.Substring
				(master, 0, nul));
			NUnit.Framework.Assert.AreSame(PacketLineIn.END, r.ReadString());
			NUnit.Framework.Assert.AreEqual("unpack error Missing tree " + t.Name, r.ReadString
				());
			NUnit.Framework.Assert.AreEqual("ng refs/heads/s n/a (unpacker error)", r.ReadString
				());
			NUnit.Framework.Assert.AreSame(PacketLineIn.END, r.ReadString());
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:47,代码来源:ReceivePackAdvertiseRefsHookTest.cs

示例4: TestUsingHiddenDeltaBaseFails

		public virtual void TestUsingHiddenDeltaBaseFails()
		{
			byte[] delta = new byte[] { unchecked((int)(0x1)), unchecked((int)(0x1)), unchecked(
				(int)(0x1)), (byte)('c') };
			TestRepository<Repository> s = new TestRepository<Repository>(src);
			RevCommit N = s.Commit().Parent(B).Add("q", s.Blob(BinaryDelta.Apply(dst.Open(b).
				GetCachedBytes(), delta))).Create();
			TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
			PackHeader(pack, 3);
			Copy(pack, src.Open(N));
			Copy(pack, src.Open(s.ParseBody(N).Tree));
			pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
			b.CopyRawTo(pack);
			Deflate(pack, delta);
			Digest(pack);
			TemporaryBuffer.Heap inBuf = new TemporaryBuffer.Heap(1024);
			PacketLineOut inPckLine = new PacketLineOut(inBuf);
			inPckLine.WriteString(ObjectId.ZeroId.Name + ' ' + N.Name + ' ' + "refs/heads/s" 
				+ '\0' + BasePackPushConnection.CAPABILITY_REPORT_STATUS);
			inPckLine.End();
			pack.WriteTo(inBuf, PM);
			TemporaryBuffer.Heap outBuf = new TemporaryBuffer.Heap(1024);
			ReceivePack rp = new ReceivePack(dst);
			rp.SetCheckReceivedObjects(true);
			rp.SetCheckReferencedObjectsAreReachable(true);
			rp.SetAdvertiseRefsHook(new ReceivePackAdvertiseRefsHookTest.HidePrivateHook());
			try
			{
				Receive(rp, inBuf, outBuf);
				NUnit.Framework.Assert.Fail("Expected UnpackException");
			}
			catch (UnpackException failed)
			{
				Exception err = failed.InnerException;
				NUnit.Framework.Assert.IsTrue(err is MissingObjectException);
				MissingObjectException moe = (MissingObjectException)err;
				NUnit.Framework.Assert.AreEqual(b, moe.GetObjectId());
			}
			PacketLineIn r = AsPacketLineIn(outBuf);
			string master = r.ReadString();
			int nul = master.IndexOf('\0');
			NUnit.Framework.Assert.IsTrue(nul > 0, "has capability list");
			NUnit.Framework.Assert.AreEqual(B.Name + ' ' + R_MASTER, Sharpen.Runtime.Substring
				(master, 0, nul));
			NUnit.Framework.Assert.AreSame(PacketLineIn.END, r.ReadString());
			NUnit.Framework.Assert.AreEqual("unpack error Missing blob " + b.Name, r.ReadString
				());
			NUnit.Framework.Assert.AreEqual("ng refs/heads/s n/a (unpacker error)", r.ReadString
				());
			NUnit.Framework.Assert.AreSame(PacketLineIn.END, r.ReadString());
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:51,代码来源:ReceivePackAdvertiseRefsHookTest.cs

示例5: TestSuccess

		public virtual void TestSuccess()
		{
			// Manually force a delta of an object so we reuse it later.
			//
			TemporaryBuffer.Heap pack = new TemporaryBuffer.Heap(1024);
			PackHeader(pack, 2);
			pack.Write((Constants.OBJ_BLOB) << 4 | 1);
			Deflate(pack, new byte[] { (byte)('a') });
			pack.Write((Constants.OBJ_REF_DELTA) << 4 | 4);
			a.CopyRawTo(pack);
			Deflate(pack, new byte[] { unchecked((int)(0x1)), unchecked((int)(0x1)), unchecked(
				(int)(0x1)), (byte)('b') });
			Digest(pack);
			OpenPack(pack);
			// Verify the only storage of b is our packed delta above.
			//
			ObjectDirectory od = (ObjectDirectory)src.ObjectDatabase;
			NUnit.Framework.Assert.IsTrue(src.HasObject(b), "has b");
			NUnit.Framework.Assert.IsFalse(od.FileFor(b).Exists(), "b not loose");
			// Now use b but in a different commit than what is hidden.
			//
			TestRepository s = new TestRepository<Repository>(src);
			RevCommit N = s.Commit().Parent(B).Add("q", b).Create();
			s.Update(R_MASTER, N);
			// Push this new content to the remote, doing strict validation.
			//
			TransportLocal t = new _TransportLocal_210(this, src, UriOf(dst), dst.Directory);
			RemoteRefUpdate u = new RemoteRefUpdate(src, R_MASTER, R_MASTER, false, null, null
				);
			//
			//
			// src name
			// dst name
			// do not force update
			// local tracking branch
			// expected id
			PushResult r;
			try
			{
				t.SetPushThin(true);
				r = t.Push(PM, Sharpen.Collections.Singleton(u));
			}
			finally
			{
				t.Close();
			}
			NUnit.Framework.Assert.IsNotNull(r, "have result");
			NUnit.Framework.Assert.IsNull(r.GetAdvertisedRef(R_PRIVATE), "private not advertised"
				);
			NUnit.Framework.Assert.AreEqual(RemoteRefUpdate.Status.OK, u.GetStatus(), "master updated"
				);
			NUnit.Framework.Assert.AreEqual(N, dst.Resolve(R_MASTER));
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:53,代码来源:ReceivePackAdvertiseRefsHookTest.cs

示例6: SetUp

		public override void SetUp()
		{
			base.SetUp();
			tr = new TestRepository<Repository>(db);
			reader = db.NewObjectReader();
			inserter = db.NewObjectInserter();
			noRoot = NoteMap.NewMap(null, reader);
			empty = NoteMap.NewEmptyMap();
			noteAId = tr.Blob("a");
			noteAContent = "noteAContent";
			noteABlob = tr.Blob(noteAContent);
			sampleTree_a = tr.Commit().Add(noteAId.Name, noteABlob).Create();
			tr.ParseBody(sampleTree_a);
			map_a = NoteMap.Read(reader, sampleTree_a);
			noteBId = tr.Blob("b");
			noteBContent = "noteBContent";
			noteBBlob = tr.Blob(noteBContent);
			sampleTree_a_b = tr.Commit().Add(noteAId.Name, noteABlob).Add(noteBId.Name, noteBBlob
				).Create();
			tr.ParseBody(sampleTree_a_b);
			map_a_b = NoteMap.Read(reader, sampleTree_a_b);
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:22,代码来源:NoteMapMergerTest.cs


注:本文中的TestRepository.Commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。