本文整理汇总了C#中NGit.Api.Git.CherryPick方法的典型用法代码示例。如果您正苦于以下问题:C# Git.CherryPick方法的具体用法?C# Git.CherryPick怎么用?C# Git.CherryPick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NGit.Api.Git
的用法示例。
在下文中一共展示了Git.CherryPick方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCherryPick
public virtual void TestCherryPick()
{
Git git = new Git(db);
WriteTrashFile("a", "first line\nsec. line\nthird line\n");
git.Add().AddFilepattern("a").Call();
RevCommit firstCommit = 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();
git.BranchCreate().SetName("side").SetStartPoint(firstCommit).Call();
CheckoutBranch("refs/heads/side");
WriteTrashFile("a", "first line\nsec. line\nthird line\nfeature++\n");
git.Add().AddFilepattern("a").Call();
git.Commit().SetMessage("enhanced a").Call();
git.CherryPick().Include(fixingA).Call();
NUnit.Framework.Assert.IsFalse(new FilePath(db.WorkTree, "b").Exists());
CheckFile(new FilePath(db.WorkTree, "a"), "first line\nsecond line\nthird line\nfeature++\n"
);
Iterator<RevCommit> history = git.Log().Call().Iterator();
NUnit.Framework.Assert.AreEqual("fixed a", history.Next().GetFullMessage());
NUnit.Framework.Assert.AreEqual("enhanced a", history.Next().GetFullMessage());
NUnit.Framework.Assert.AreEqual("create a", history.Next().GetFullMessage());
NUnit.Framework.Assert.IsFalse(history.HasNext());
}
示例2: DoCherryPickAndCheckResult
/// <exception cref="System.Exception"></exception>
private void DoCherryPickAndCheckResult(Git git, RevCommit sideCommit, ResolveMerger.MergeFailureReason
reason)
{
// get current index state
string indexState = IndexState(CONTENT);
// cherry-pick
CherryPickResult result = git.CherryPick().Include(sideCommit.Id).Call();
NUnit.Framework.Assert.AreEqual(CherryPickResult.CherryPickStatus.FAILED, result.
GetStatus());
// staged file a causes DIRTY_INDEX
NUnit.Framework.Assert.AreEqual(1, result.GetFailingPaths().Count);
NUnit.Framework.Assert.AreEqual(reason, result.GetFailingPaths().Get("a"));
NUnit.Framework.Assert.AreEqual("a(modified)", Read(new FilePath(db.WorkTree, "a"
)));
// index shall be unchanged
NUnit.Framework.Assert.AreEqual(indexState, IndexState(CONTENT));
NUnit.Framework.Assert.AreEqual(RepositoryState.SAFE, db.GetRepositoryState());
}
示例3: 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());
}
示例4: TestCherryPickConflictResolution
public virtual void TestCherryPickConflictResolution()
{
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.IsTrue(new FilePath(db.Directory, Constants.MERGE_MSG).Exists
());
NUnit.Framework.Assert.AreEqual("side\n\nConflicts:\n\ta\n", db.ReadMergeCommitMsg
());
NUnit.Framework.Assert.IsTrue(new FilePath(db.Directory, Constants.CHERRY_PICK_HEAD
).Exists());
NUnit.Framework.Assert.AreEqual(sideCommit.Id, db.ReadCherryPickHead());
NUnit.Framework.Assert.AreEqual(RepositoryState.CHERRY_PICKING, db.GetRepositoryState
());
// Resolve
WriteTrashFile("a", "a");
git.Add().AddFilepattern("a").Call();
NUnit.Framework.Assert.AreEqual(RepositoryState.CHERRY_PICKING_RESOLVED, db.GetRepositoryState
());
git.Commit().SetOnly("a").SetMessage("resolve").Call();
NUnit.Framework.Assert.AreEqual(RepositoryState.SAFE, db.GetRepositoryState());
}
示例5: TestCherryPickOverExecutableChangeOnNonExectuableFileSystem
public virtual void TestCherryPickOverExecutableChangeOnNonExectuableFileSystem()
{
Git git = new Git(db);
FilePath file = WriteTrashFile("test.txt", "a");
NUnit.Framework.Assert.IsNotNull(git.Add().AddFilepattern("test.txt").Call());
NUnit.Framework.Assert.IsNotNull(git.Commit().SetMessage("commit1").Call());
NUnit.Framework.Assert.IsNotNull(git.Checkout().SetCreateBranch(true).SetName("a"
).Call());
WriteTrashFile("test.txt", "b");
NUnit.Framework.Assert.IsNotNull(git.Add().AddFilepattern("test.txt").Call());
RevCommit commit2 = git.Commit().SetMessage("commit2").Call();
NUnit.Framework.Assert.IsNotNull(commit2);
NUnit.Framework.Assert.IsNotNull(git.Checkout().SetName(Constants.MASTER).Call());
DirCache cache = db.LockDirCache();
cache.GetEntry("test.txt").FileMode = FileMode.EXECUTABLE_FILE;
cache.Write();
NUnit.Framework.Assert.IsTrue(cache.Commit());
cache.Unlock();
NUnit.Framework.Assert.IsNotNull(git.Commit().SetMessage("commit3").Call());
db.FileSystem.SetExecute(file, false);
git.GetRepository().GetConfig().SetBoolean(ConfigConstants.CONFIG_CORE_SECTION, null
, ConfigConstants.CONFIG_KEY_FILEMODE, false);
CherryPickResult result = git.CherryPick().Include(commit2).Call();
NUnit.Framework.Assert.IsNotNull(result);
NUnit.Framework.Assert.AreEqual(CherryPickResult.CherryPickStatus.OK, result.GetStatus
());
}
示例6: TestCherryPickOurCommitName
public virtual void TestCherryPickOurCommitName()
{
Git git = new Git(db);
RevCommit sideCommit = PrepareCherryPick(git);
CherryPickResult result = git.CherryPick().Include(sideCommit.Id).SetOurCommitName
("custom name").Call();
NUnit.Framework.Assert.AreEqual(CherryPickResult.CherryPickStatus.CONFLICTING, result
.GetStatus());
string expected = "<<<<<<< custom name\na(master)\n=======\na(side)\n>>>>>>> 527460a side\n";
CheckFile(new FilePath(db.WorkTree, "a"), expected);
}