using LibGit2Sharp.Handlers;
using LibGit2Sharp;
// Define source/dest
var source = "https://github.com/org/blah.git";
var dest = "c:\\temp\\blah\\";
// Clone fails if destination already exists
if (Directory.Exists(dest))
{
Console.WriteLine("Directory exists and is not an empty directory, please fix and try again.");
Environment.Exit(0);
}
// Create a delegate to handle progress events
var gitProgress = new ProgressHandler((serverProgressOutput) =>
{
// Print output to console
Console.Write(serverProgressOutput);
// Move cursor to beginning of line
(int left, int top) = Console.GetCursorPosition();
Console.SetCursorPosition(0,top);
return true;
});
// Clone repo using progress handler
var x = Repository.Clone(source, dest, new CloneOptions { OnProgress = gitProgress });
1条答案
按热度按时间gk7wooem1#
下面是一个例子: