当前位置: 首页>>代码示例>>C#>>正文


C# Repository.Fetch方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:Xarlot,项目名称:DXVcs2Git,代码行数:30,代码来源:GitServiceTests.cs

示例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;
        }
开发者ID:840645576,项目名称:LeagueSharp.Loader,代码行数:57,代码来源:GitUpdater.cs

示例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);
                }
            }
        }
开发者ID:immeraufdemhund,项目名称:SourceLog,代码行数:20,代码来源:GitPlugin.cs

示例4: FetchChanges

 public void FetchChanges(string repoPath)
 {
     Repository repository = new Repository(repoPath);
     repository.Fetch("origin");
 }
开发者ID:MichaelSL,项目名称:nugetbuilder,代码行数:5,代码来源:GitManager.cs

示例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);
        }
开发者ID:projectkudu,项目名称:KuduCalf,代码行数:31,代码来源:KuduCalfWeb.ashx.cs


注:本文中的LibGit2Sharp.Repository.Fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。