本文整理汇总了C#中IRepository.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.Reset方法的具体用法?C# IRepository.Reset怎么用?C# IRepository.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.Reset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResetAndCleanWorkingDirectory
/// <summary>
/// Reset and clean current working directory. This will ensure that the current
/// working directory matches the current Head commit.
/// </summary>
/// <param name="repo">Repository whose current working directory should be operated on.</param>
private void ResetAndCleanWorkingDirectory(IRepository repo)
{
// Reset the index and the working tree.
repo.Reset(ResetMode.Hard);
// Clean the working directory.
repo.RemoveUntrackedFiles();
}
示例2: AssertStage
private static void AssertStage(bool? ignorecase, IRepository repo, string path)
{
try
{
repo.Index.Stage(path);
Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(path));
repo.Reset();
Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(path));
}
catch (ArgumentException)
{
Assert.False(ignorecase ?? true);
}
}
示例3: UpdateGit
bool UpdateGit(IRepository repo)
{
var recompileNeeded = true;
using (var _ = new ChangingOutput("Updating source code . . ."))
{
_.FinishLine();
using (var t = new ChangingOutput("Fetching updates from GitHub . . ."))
{
repo.Fetch("origin", new FetchOptions()
{
OnTransferProgress = (x) =>
{
t.PrintProgress((double) x.ReceivedObjects/x.TotalObjects);
return true;
}
});
t.PrintResult(true);
}
var currentCommit = repo.Head.Tip;
MergeResult result;
try
{
using (var t = new ChangingOutput("Merging in updates . . ."))
{
result = repo.Merge(repo.Head.TrackedBranch, new Signature(Environment.UserName, "[email protected]", DateTime.Now),
new MergeOptions
{
CommitOnSuccess = true,
FileConflictStrategy = CheckoutFileConflictStrategy.Ours,
MergeFileFavor = MergeFileFavor.Normal,
OnCheckoutProgress = (n, processed, total) =>
{
t.PrintProgress((double) processed/total);
},
});
t.PrintResult(result.Status != MergeStatus.Conflicts);
}
if (result.Status == MergeStatus.UpToDate)
{
Console.WriteLine("Source was already up to date");
recompileNeeded = RestoreDeleteFiles(repo);
_.PrintResult(true);
}
else if (result.Status == MergeStatus.Conflicts)
{
throw new MergeConflictException();
}
else
{
Console.WriteLine("Updated to {0} : {1}", result.Commit.Sha.Substring(0, 10), result.Commit.MessageShort);
_.PrintResult(true);
}
}
catch (MergeConflictException)
{
Console.WriteLine("Merge resulted in conflicts. This usually indictates a user-edited source");
Console.WriteLine("Your Aura will NOT be updated until you undo your changes to the files.");
Console.WriteLine("This is a bad thing, so fix it ASAP.");
Console.WriteLine("NOTE: If you're trying to make configuration changes, use the \"user\" folders instead.");
Console.WriteLine("Rolling back merge...");
repo.Reset(currentCommit);
recompileNeeded = false;
_.PrintResult(false);
}
return recompileNeeded;
}
}