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


C# Git.Status方法代碼示例

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


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

示例1: TestEmptyStatus

		public virtual void TestEmptyStatus()
		{
			Git git = new Git(db);
			Status stat = git.Status().Call();
			NUnit.Framework.Assert.AreEqual(0, stat.GetAdded().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetChanged().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetModified().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetRemoved().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetUntracked().Count);
		}
開發者ID:shoff,項目名稱:ngit,代碼行數:11,代碼來源:StatusCommandTest.cs

示例2: TestDifferentStates

		public virtual void TestDifferentStates()
		{
			Git git = new Git(db);
			WriteTrashFile("a", "content of a");
			WriteTrashFile("b", "content of b");
			WriteTrashFile("c", "content of c");
			git.Add().AddFilepattern("a").AddFilepattern("b").Call();
			Status stat = git.Status().Call();
			NUnit.Framework.Assert.AreEqual(Set("a", "b"), Set (stat.GetAdded()));
			NUnit.Framework.Assert.AreEqual(0, stat.GetChanged().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetModified().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetRemoved().Count);
			NUnit.Framework.Assert.AreEqual(Set("c"), Set (stat.GetUntracked()));
			git.Commit().SetMessage("initial").Call();
			WriteTrashFile("a", "modified content of a");
			WriteTrashFile("b", "modified content of b");
			WriteTrashFile("d", "content of d");
			git.Add().AddFilepattern("a").AddFilepattern("d").Call();
			WriteTrashFile("a", "again modified content of a");
			stat = git.Status().Call();
			NUnit.Framework.Assert.AreEqual(Set("d"), Set (stat.GetAdded()));
			NUnit.Framework.Assert.AreEqual(Set("a"), Set (stat.GetChanged()));
			NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count);
			NUnit.Framework.Assert.AreEqual(Set("b", "a"), Set (stat.GetModified()));
			NUnit.Framework.Assert.AreEqual(0, stat.GetRemoved().Count);
			NUnit.Framework.Assert.AreEqual(Set("c"), Set (stat.GetUntracked()));
			git.Add().AddFilepattern(".").Call();
			git.Commit().SetMessage("second").Call();
			stat = git.Status().Call();
			NUnit.Framework.Assert.AreEqual(0, stat.GetAdded().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetChanged().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetModified().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetRemoved().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetUntracked().Count);
			DeleteTrashFile("a");
			NUnit.Framework.Assert.IsFalse(new FilePath(git.GetRepository().WorkTree, "a").Exists
				());
			git.Add().AddFilepattern("a").SetUpdate(true).Call();
			WriteTrashFile("a", "recreated content of a");
			stat = git.Status().Call();
			NUnit.Framework.Assert.AreEqual(0, stat.GetAdded().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetChanged().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetMissing().Count);
			NUnit.Framework.Assert.AreEqual(0, stat.GetModified().Count);
			NUnit.Framework.Assert.AreEqual(Set("a"), Set (stat.GetRemoved()));
			NUnit.Framework.Assert.AreEqual(Set("a"), Set (stat.GetUntracked()));
			git.Commit().SetMessage("t").Call();
		}
開發者ID:shoff,項目名稱:ngit,代碼行數:50,代碼來源:StatusCommandTest.cs

示例3: TestSquashMergeConflict

 public virtual void TestSquashMergeConflict()
 {
     Git git = new Git(db);
     WriteTrashFile("file1", "file1");
     git.Add().AddFilepattern("file1").Call();
     RevCommit first = git.Commit().SetMessage("initial commit").Call();
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file1").Exists());
     CreateBranch(first, "refs/heads/branch1");
     WriteTrashFile("file2", "master");
     git.Add().AddFilepattern("file2").Call();
     RevCommit second = git.Commit().SetMessage("second commit").Call();
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists());
     CheckoutBranch("refs/heads/branch1");
     WriteTrashFile("file2", "branch");
     git.Add().AddFilepattern("file2").Call();
     RevCommit third = git.Commit().SetMessage("third commit").Call();
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists());
     CheckoutBranch("refs/heads/master");
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file1").Exists());
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists());
     MergeCommandResult result = git.Merge().Include(db.GetRef("branch1")).SetSquash(true
         ).Call();
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file1").Exists());
     NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "file2").Exists());
     NUnit.Framework.Assert.AreEqual(MergeStatus.CONFLICTING, result.GetMergeStatus());
     NUnit.Framework.Assert.IsNull(result.GetNewHead());
     NUnit.Framework.Assert.AreEqual(second, db.Resolve(Constants.HEAD + "^{commit}"));
     NUnit.Framework.Assert.AreEqual("Squashed commit of the following:\n\ncommit " +
         third.GetName() + "\nAuthor: " + third.GetAuthorIdent().GetName() + " <" + third
         .GetAuthorIdent().GetEmailAddress() + ">\nDate:   " + dateFormatter.FormatDate(third
         .GetAuthorIdent()) + "\n\n\tthird commit\n", db.ReadSquashCommitMsg());
     NUnit.Framework.Assert.AreEqual("\nConflicts:\n\tfile2\n", db.ReadMergeCommitMsg(
         ));
     Status stat = git.Status().Call();
     NUnit.Framework.CollectionAssert.AreEquivalent(StatusCommandTest.Set("file2"), stat.GetConflicting
         ());
 }
開發者ID:OrangeCloudNetworks,項目名稱:ngit,代碼行數:37,代碼來源:MergeCommandTest.cs

示例4: GetSubmodulesToUpdate

		bool GetSubmodulesToUpdate (List<string> updateSubmodules)
		{
			List<string> dirtySubmodules = new List<string> ();

			// Iterate submodules and do status.
			// SubmoduleStatus does not report changes for dirty submodules.
			foreach (var submodule in CachedSubmodules) {
				var submoduleGit = new NGit.Api.Git (submodule.Item2);
				var statusCommand = submoduleGit.Status ();
				var status = statusCommand.Call ();

				if (status.IsClean ())
					updateSubmodules.Add (submodule.Item1);
				else
					dirtySubmodules.Add (submodule.Item1);
			}

			if (dirtySubmodules.Count != 0) {
				StringBuilder submodules = new StringBuilder (Environment.NewLine + Environment.NewLine);
				foreach (var item in dirtySubmodules)
					submodules.AppendLine (item);

				AlertButton response = MessageService.GenericAlert (
					MonoDevelop.Ide.Gui.Stock.Question,
					GettextCatalog.GetString ("You have local changes in the submodules below"),
					GettextCatalog.GetString ("Do you want continue? Detached HEADs will have their changes lost.{0}", submodules.ToString ()),
					new AlertButton[] {
							AlertButton.No,
							new AlertButton ("Only unchanged"),
							AlertButton.Yes
						}
				);

				if (response == AlertButton.No)
					return false;

				if (response == AlertButton.Yes)
					updateSubmodules.AddRange (dirtySubmodules);
			}
			return true;
		}
開發者ID:Chertolom,項目名稱:monodevelop,代碼行數:41,代碼來源:GitRepository.cs

示例5: GetStatus

 private static Status GetStatus(Git repository)
 {
     var call = repository.Status();
     return call.Call();
 }
開發者ID:FixYourShit,項目名稱:shitfixer,代碼行數:5,代碼來源:ShitFixer.cs

示例6: TestSubmoduleDeleteNotStagedWithUpdate

 public virtual void TestSubmoduleDeleteNotStagedWithUpdate()
 {
     Git git = new Git(db);
     WriteTrashFile("file.txt", "content");
     git.Add().AddFilepattern("file.txt").Call();
     NUnit.Framework.Assert.IsNotNull(git.Commit().SetMessage("create file").Call());
     SubmoduleAddCommand command = new SubmoduleAddCommand(db);
     string path = "sub";
     command.SetPath(path);
     string uri = db.Directory.ToURI().ToString();
     command.SetURI(uri);
     Repository repo = command.Call();
     NUnit.Framework.Assert.IsNotNull(repo);
     NUnit.Framework.Assert.IsNotNull(git.Commit().SetMessage("add submodule").Call());
     NUnit.Framework.Assert.IsTrue(git.Status().Call().IsClean());
     FileUtils.Delete(repo.WorkTree, FileUtils.RECURSIVE);
     FileUtils.Mkdir(new FilePath(db.WorkTree, path), false);
     NUnit.Framework.Assert.IsNotNull(git.Add().AddFilepattern(".").SetUpdate(true).Call
         ());
     Status status = git.Status().Call();
     NUnit.Framework.Assert.IsFalse(status.IsClean());
     NUnit.Framework.Assert.IsTrue(status.GetAdded().IsEmpty());
     NUnit.Framework.Assert.IsTrue(status.GetChanged().IsEmpty());
     NUnit.Framework.Assert.IsTrue(status.GetRemoved().IsEmpty());
     NUnit.Framework.Assert.IsTrue(status.GetUntracked().IsEmpty());
     NUnit.Framework.Assert.IsTrue(status.GetModified().IsEmpty());
     NUnit.Framework.Assert.AreEqual(1, status.GetMissing().Count);
     NUnit.Framework.Assert.AreEqual(path, status.GetMissing().Iterator().Next());
 }
開發者ID:gaijenbon,項目名稱:ngit,代碼行數:29,代碼來源:AddCommandTest.cs


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