当前位置: 首页>>代码示例>>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;未经允许,请勿转载。