本文整理汇总了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());
}
示例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"));
}
示例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)
{
}
}
示例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);
}
示例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());
}
示例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));
}