本文整理汇总了C#中NGit.Api.Git.Revert方法的典型用法代码示例。如果您正苦于以下问题:C# Git.Revert方法的具体用法?C# Git.Revert怎么用?C# Git.Revert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NGit.Api.Git
的用法示例。
在下文中一共展示了Git.Revert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRevert
public virtual void TestRevert()
{
Git git = new Git(db);
WriteTrashFile("a", "first line\nsec. line\nthird line\n");
git.Add().AddFilepattern("a").Call();
git.Commit().SetMessage("create a").Call();
WriteTrashFile("b", "content\n");
git.Add().AddFilepattern("b").Call();
git.Commit().SetMessage("create b").Call();
WriteTrashFile("a", "first line\nsec. line\nthird line\nfourth line\n");
git.Add().AddFilepattern("a").Call();
git.Commit().SetMessage("enlarged a").Call();
WriteTrashFile("a", "first line\nsecond line\nthird line\nfourth line\n");
git.Add().AddFilepattern("a").Call();
RevCommit fixingA = git.Commit().SetMessage("fixed a").Call();
WriteTrashFile("b", "first line\n");
git.Add().AddFilepattern("b").Call();
git.Commit().SetMessage("fixed b").Call();
git.Revert().Include(fixingA).Call();
NUnit.Framework.Assert.IsTrue(new FilePath(db.WorkTree, "b").Exists());
CheckFile(new FilePath(db.WorkTree, "a"), "first line\nsec. line\nthird line\nfourth line\n"
);
Iterator<RevCommit> history = git.Log().Call().Iterator();
RevCommit revertCommit = history.Next();
string expectedMessage = "Revert \"fixed a\"\n\n" + "This reverts commit " + fixingA
.Id.GetName() + ".\n";
NUnit.Framework.Assert.AreEqual(expectedMessage, revertCommit.GetFullMessage());
NUnit.Framework.Assert.AreEqual("fixed b", history.Next().GetFullMessage());
NUnit.Framework.Assert.AreEqual("fixed a", history.Next().GetFullMessage());
NUnit.Framework.Assert.AreEqual("enlarged a", history.Next().GetFullMessage());
NUnit.Framework.Assert.AreEqual("create b", history.Next().GetFullMessage());
NUnit.Framework.Assert.AreEqual("create a", history.Next().GetFullMessage());
NUnit.Framework.Assert.IsFalse(history.HasNext());
}
示例2: RevertRevision
public override void RevertRevision (FilePath localPath, Revision revision, IProgressMonitor monitor)
{
var git = new NGit.Api.Git (GetRepository (localPath));
var gitRev = (GitRevision)revision;
var revert = git.Revert ().Include (gitRev.Commit.ToObjectId ());
var newRevision = revert.Call ();
var revertResult = revert.GetFailingResult ();
if (revertResult == null) {
monitor.ReportSuccess (GettextCatalog.GetString ("Revision {0} successfully reverted", gitRev));
} else {
var errorMessage = GettextCatalog.GetString ("Could not revert commit {0}", gitRev);
var description = GettextCatalog.GetString ("The following files had merge conflicts");
description += Environment.NewLine + string.Join (Environment.NewLine, revertResult.GetFailingPaths ().Keys);
monitor.ReportError (errorMessage, new UserException (errorMessage, description));
}
}