當前位置: 首頁>>代碼示例>>C#>>正文


C# Git.Reset方法代碼示例

本文整理匯總了C#中NGit.Api.Git.Reset方法的典型用法代碼示例。如果您正苦於以下問題:C# Git.Reset方法的具體用法?C# Git.Reset怎麽用?C# Git.Reset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NGit.Api.Git的用法示例。


在下文中一共展示了Git.Reset方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestCherryPickConflictReset

		public virtual void TestCherryPickConflictReset()
		{
			Git git = new Git(db);
			RevCommit sideCommit = PrepareCherryPick(git);
			CherryPickResult result = git.CherryPick().Include(sideCommit.Id).Call();
			NUnit.Framework.Assert.AreEqual(CherryPickResult.CherryPickStatus.CONFLICTING, result
				.GetStatus());
			NUnit.Framework.Assert.AreEqual(RepositoryState.CHERRY_PICKING, db.GetRepositoryState
				());
			NUnit.Framework.Assert.IsTrue(new FilePath(db.Directory, Constants.CHERRY_PICK_HEAD
				).Exists());
			git.Reset().SetMode(ResetCommand.ResetType.MIXED).SetRef("HEAD").Call();
			NUnit.Framework.Assert.AreEqual(RepositoryState.SAFE, db.GetRepositoryState());
			NUnit.Framework.Assert.IsFalse(new FilePath(db.Directory, Constants.CHERRY_PICK_HEAD
				).Exists());
		}
開發者ID:shoff,項目名稱:ngit,代碼行數:16,代碼來源:CherryPickCommandTest.cs

示例2: TestResetHardFromIndexEntryWithoutFileToTreeWithoutFile

 public virtual void TestResetHardFromIndexEntryWithoutFileToTreeWithoutFile()
 {
     Git git = new Git(db);
     WriteTrashFile("x", "x");
     git.Add().AddFilepattern("x").Call();
     RevCommit id1 = git.Commit().SetMessage("c1").Call();
     WriteTrashFile("f/g", "f/g");
     git.Rm().AddFilepattern("x").Call();
     git.Add().AddFilepattern("f/g").Call();
     git.Commit().SetMessage("c2").Call();
     DeleteTrashFile("f/g");
     DeleteTrashFile("f");
     // The actual test
     git.Reset().SetMode(ResetCommand.ResetType.HARD).SetRef(id1.GetName()).Call();
     AssertIndex(Mkmap("x", "x"));
 }
開發者ID:JamesChan,項目名稱:ngit,代碼行數:16,代碼來源:DirCacheCheckoutTest.cs

示例3: TestResetToNonexistingHEAD

 public virtual void TestResetToNonexistingHEAD()
 {
     // create a file in the working tree of a fresh repo
     git = new Git(db);
     WriteTrashFile("f", "content");
     try
     {
         git.Reset().SetRef(Constants.HEAD).Call();
         NUnit.Framework.Assert.Fail("Expected JGitInternalException didn't occur");
     }
     catch (JGitInternalException)
     {
     }
 }
開發者ID:voluminat0,項目名稱:ngit,代碼行數:14,代碼來源:ResetCommandTest.cs

示例4: TestMixedResetRetainsSizeAndModifiedTime

 public virtual void TestMixedResetRetainsSizeAndModifiedTime()
 {
     git = new Git(db);
     WriteTrashFile("a.txt", "a").SetLastModified(Runtime.CurrentTimeMillis() - 60 * 1000
         );
     NUnit.Framework.Assert.IsNotNull(git.Add().AddFilepattern("a.txt").Call());
     NUnit.Framework.Assert.IsNotNull(git.Commit().SetMessage("a commit").Call());
     WriteTrashFile("b.txt", "b").SetLastModified(Runtime.CurrentTimeMillis() - 60 * 1000
         );
     NUnit.Framework.Assert.IsNotNull(git.Add().AddFilepattern("b.txt").Call());
     RevCommit commit2 = git.Commit().SetMessage("b commit").Call();
     NUnit.Framework.Assert.IsNotNull(commit2);
     DirCache cache = db.ReadDirCache();
     DirCacheEntry aEntry = cache.GetEntry("a.txt");
     NUnit.Framework.Assert.IsNotNull(aEntry);
     NUnit.Framework.Assert.IsTrue(aEntry.Length > 0);
     NUnit.Framework.Assert.IsTrue(aEntry.LastModified > 0);
     DirCacheEntry bEntry = cache.GetEntry("b.txt");
     NUnit.Framework.Assert.IsNotNull(bEntry);
     NUnit.Framework.Assert.IsTrue(bEntry.Length > 0);
     NUnit.Framework.Assert.IsTrue(bEntry.LastModified > 0);
     git.Reset().SetMode(ResetCommand.ResetType.MIXED).SetRef(commit2.GetName()).Call(
         );
     cache = db.ReadDirCache();
     DirCacheEntry mixedAEntry = cache.GetEntry("a.txt");
     NUnit.Framework.Assert.IsNotNull(mixedAEntry);
     NUnit.Framework.Assert.AreEqual(aEntry.LastModified, mixedAEntry.LastModified);
     NUnit.Framework.Assert.AreEqual(aEntry.LastModified, mixedAEntry.LastModified);
     DirCacheEntry mixedBEntry = cache.GetEntry("b.txt");
     NUnit.Framework.Assert.IsNotNull(mixedBEntry);
     NUnit.Framework.Assert.AreEqual(bEntry.LastModified, mixedBEntry.LastModified);
     NUnit.Framework.Assert.AreEqual(bEntry.LastModified, mixedBEntry.LastModified);
 }
開發者ID:voluminat0,項目名稱:ngit,代碼行數:33,代碼來源:ResetCommandTest.cs

示例5: TestHardResetAfterSquashMerge

 public virtual void TestHardResetAfterSquashMerge()
 {
     Git g = new Git(db);
     WriteTrashFile("file1", "file1");
     g.Add().AddFilepattern("file1").Call();
     RevCommit first = g.Commit().SetMessage("initial commit").Call();
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file1").Exists());
     CreateBranch(first, "refs/heads/branch1");
     CheckoutBranch("refs/heads/branch1");
     WriteTrashFile("file2", "file2");
     g.Add().AddFilepattern("file2").Call();
     g.Commit().SetMessage("second commit").Call();
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists());
     CheckoutBranch("refs/heads/master");
     MergeCommandResult result = g.Merge().Include(db.GetRef("branch1")).SetSquash(true
         ).Call();
     NUnit.Framework.Assert.AreEqual(MergeStatus.FAST_FORWARD_SQUASHED, result.GetMergeStatus
         ());
     NUnit.Framework.Assert.IsNotNull(db.ReadSquashCommitMsg());
     g.Reset().SetMode(ResetCommand.ResetType.HARD).SetRef(first.GetName()).Call();
     NUnit.Framework.Assert.IsNull(db.ReadSquashCommitMsg());
 }
開發者ID:voluminat0,項目名稱:ngit,代碼行數:22,代碼來源:ResetCommandTest.cs

示例6: TestMixedResetWithUnmerged

		public virtual void TestMixedResetWithUnmerged()
		{
			git = new Git(db);
			string file = "a.txt";
			WriteTrashFile(file, "data");
			string file2 = "b.txt";
			WriteTrashFile(file2, "data");
			git.Add().AddFilepattern(file).AddFilepattern(file2).Call();
			git.Commit().SetMessage("commit").Call();
			DirCache index = db.LockDirCache();
			DirCacheBuilder builder = index.Builder();
			builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 1, string.Empty));
			builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 2, string.Empty));
			builder.Add(CreateEntry(file, FileMode.REGULAR_FILE, 3, string.Empty));
			NUnit.Framework.Assert.IsTrue(builder.Commit());
			NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644, stage:1]" + "[a.txt, mode:100644, stage:2]"
				 + "[a.txt, mode:100644, stage:3]", IndexState(0));
			git.Reset().SetMode(ResetCommand.ResetType.MIXED).Call();
			NUnit.Framework.Assert.AreEqual("[a.txt, mode:100644]" + "[b.txt, mode:100644]", 
				IndexState(0));
		}
開發者ID:LunarLanding,項目名稱:ngit,代碼行數:21,代碼來源:ResetCommandTest.cs


注:本文中的NGit.Api.Git.Reset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。