Reputation: 37
Can anyone guide me how to get progress of clone a git repo more than 1gb from public url
While cloning
Repository.clone("url");
Upvotes: 1
Views: 400
Reputation: 734
Here's an example:
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 });
Upvotes: 2