本文整理汇总了C#中LibGit2Sharp.Repository.MergeFetchedRefs方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.MergeFetchedRefs方法的具体用法?C# Repository.MergeFetchedRefs怎么用?C# Repository.MergeFetchedRefs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibGit2Sharp.Repository
的用法示例。
在下文中一共展示了Repository.MergeFetchedRefs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Pull
/// <summary>
/// Fetch changes from the configured upstream remote and branch into the branch pointed at by HEAD.
/// </summary>
/// <param name="repository">The repository.</param>
/// <param name="merger">The signature to use for the merge.</param>
/// <param name="options">The options for fetch and merging.</param>
public static MergeResult Pull(Repository repository, Signature merger, PullOptions options)
{
Ensure.ArgumentNotNull(repository, "repository");
Ensure.ArgumentNotNull(merger, "merger");
Ensure.ArgumentNotNull(options, "options");
options = options ?? new PullOptions();
Branch currentBranch = repository.Head;
if (!currentBranch.IsTracking)
{
throw new LibGit2SharpException("There is no tracking information for the current branch.");
}
if (currentBranch.RemoteName == null)
{
throw new LibGit2SharpException("No upstream remote for the current branch.");
}
Commands.Fetch(repository, currentBranch.RemoteName, new string[0], options.FetchOptions, null);
return repository.MergeFetchedRefs(merger, options.MergeOptions);
}
示例2: DownloadAddon
private void DownloadAddon()
{
bool updated = false;
bool cloned = false;
if (!Directory.Exists(info.packedPath))
{
Directory.CreateDirectory(info.packedPath);
}
if (Directory.Exists(info.dlPath) && Repository.IsValid(info.dlPath))
{
using (Repository repo = new Repository(info.dlPath))
{
RepositoryStatus status = repo.RetrieveStatus();
string commit = repo.Head.Tip.Id.Sha;
// reset local changes
if (status.IsDirty)
{
repo.Reset(ResetMode.Hard);
}
// fetch & merge from origin
repo.Network.Fetch(repo.Network.Remotes["origin"]);
repo.MergeFetchedRefs(new Signature("meldii", "[email protected]", new DateTimeOffset()), new MergeOptions());
// updated
if (!repo.Head.Tip.Id.Sha.Equals(commit))
{
updated = true;
}
}
}
else
{
if (Directory.Exists(info.dlPath))
{
ForceDeleteDirectory(info.dlPath);
}
CloneOptions co = new CloneOptions();
co.BranchName = info.branch;
Repository.Clone(info.url, info.dlPath, co);
updated = true;
cloned = true;
}
//Pack & ship it
if (updated)
{
if (File.Exists(info.packedFile))
{
File.Delete(info.packedFile);
}
ZipFile zip = new ZipFile(info.packedFile);
foreach (string file in Directory.EnumerateFiles(info.dlPath, "*.*", SearchOption.AllDirectories))
{
string rPath = file.Replace(info.dlPath, "").TrimStart(new char[] { '\\', '/' });
if (!rPath.StartsWith(".git", StringComparison.CurrentCultureIgnoreCase) && !rPath.Equals("README.md", StringComparison.CurrentCultureIgnoreCase))
{
string[] split = rPath.Split(new char[] { '\\', '/' });
string zipPath = split.Length == 1 ? "" : string.Join("\\", split, 0, split.Length - 1);
zip.AddFile(file, zipPath);
}
}
zip.Save();
}
if (cloned)
{
_Copy(Path.Combine(MeldiiSettings.Self.AddonLibaryPath, info.repoName) + ".zip", info.packedFile);
}
}