本文整理汇总了C#中LibGit2Sharp.Repository.Fetch方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Fetch方法的具体用法?C# Repository.Fetch怎么用?C# Repository.Fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibGit2Sharp.Repository
的用法示例。
在下文中一共展示了Repository.Fetch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CloneRepo
public void CloneRepo()
{
var scd = BuildSelfCleaningDirectory();
CloneOptions options = new CloneOptions();
var credentials = new UsernamePasswordCredentials();
credentials.Username = Constants.Identity.Name;
credentials.Password = "q1w2e3r4t5y6";
options.CredentialsProvider += (url, fromUrl, types) => credentials;
string clonedRepoPath = Repository.Clone(testUrl, scd.DirectoryPath, options);
string file = Path.Combine(scd.DirectoryPath, "testpush.txt");
var rbg = new RandomBufferGenerator(30000);
using (var repo = new Repository(clonedRepoPath)) {
for (int i = 0; i < 1; i++) {
var network = repo.Network.Remotes.First();
FetchOptions fetchOptions = new FetchOptions();
fetchOptions.CredentialsProvider += (url, fromUrl, types) => credentials;
repo.Fetch(network.Name, fetchOptions);
File.WriteAllBytes(file, rbg.GenerateBufferFromSeed(30000));
repo.Stage(file);
Signature author = Constants.Signature;
Commit commit = repo.Commit($"Here's a commit {i + 1} i made!", author, author);
PushOptions pushOptions = new PushOptions();
pushOptions.CredentialsProvider += (url, fromUrl, types) => credentials;
repo.Network.Push(repo.Branches["master"], pushOptions);
}
}
}
示例2: Update
public static string Update(string url, Log log, string directory, string repoDirectory = null)
{
if (string.IsNullOrWhiteSpace(url))
{
Utility.Log(LogStatus.Skipped, "Updater", string.Format("No Url specified - {0}", url), log);
}
else
{
try
{
var dir = Path.Combine(directory, url.GetHashCode().ToString("X"), "trunk");
if (Repository.IsValid(dir))
{
using (var repo = new Repository(dir))
{
repo.Config.Set("user.name", Config.Instance.Username);
repo.Config.Set("user.email", Config.Instance.Username + "@joduska.me");
repo.Fetch("origin");
if (repoDirectory != null)
{
repo.CheckoutPaths("origin/master", new List<String>() { repoDirectory }, new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force });
}
else
{
repo.Checkout("origin/master", new CheckoutOptions { CheckoutModifiers = CheckoutModifiers.Force });
}
}
}
else
{
var oldPath = Path.Combine(directory, url.GetHashCode().ToString("X"));
if (Directory.Exists(oldPath))
{
Directory.Delete(oldPath, true);
}
Repository.Clone(url, dir, new CloneOptions { Checkout = true });
using (var repo = new Repository(dir))
{
repo.Config.Set("user.name", Config.Instance.Username);
repo.Config.Set("user.email", Config.Instance.Username + "@joduska.me");
}
}
return dir;
}
catch (Exception ex)
{
Utility.Log(LogStatus.Error, "Updater", string.Format("{0} - {1}", ex.Message, url), log);
}
}
return string.Empty;
}
示例3: CheckForNewLogEntriesImpl
protected override void CheckForNewLogEntriesImpl()
{
string directory;
string remote;
string branch;
GetGitSettings(out directory, out remote, out branch);
using (var repo = new Repository(directory))
{
repo.Fetch(remote);
foreach (var commit in repo.Branches[remote + "/" + branch].Commits
.Where(c => c.Committer.When.UtcDateTime > MaxDateTimeRetrieved)
.Take(30)
.OrderBy(c => c.Committer.When.UtcDateTime))
{
ProcessLogEntry(repo, commit);
}
}
}
示例4: FetchChanges
public void FetchChanges(string repoPath)
{
Repository repository = new Repository(repoPath);
repository.Fetch("origin");
}
示例5: TryUpdateRepository
public void TryUpdateRepository(HttpContext context)
{
var targetWebRoot = GetTargetWebRoot();
if (String.IsNullOrEmpty(targetWebRoot))
{
SendResponse(context, 404, "No web root target.");
return;
}
if (!Repository.IsValid(targetWebRoot))
{
SendResponse(context, 404, "No repository configured at: {0}", targetWebRoot);
return;
}
string snapshotId = null;
string siteId = null;
var handlers = GetProgressHandlers(context);
using (var repo = new Repository(targetWebRoot))
{
repo.Fetch("origin", onCompletion: handlers.CompletionHandler,
onTransferProgress: handlers.TransferProgressHandler,
onProgress: msg => SendProgress(context, msg));
repo.Reset(ResetOptions.Hard, "origin/master");
snapshotId = GetLatestSnapShotId(repo);
siteId = HostingEnvironment.ApplicationHost.GetSiteID();
var url = GetScmUri(repo);
Protocol.KuduCalfCmdUpdateSiteStatus(url, siteId, snapshotId);
}
SendResponse(context, 200, "Updated root {0} of subscriber {1} to {2}", targetWebRoot, siteId, snapshotId);
}