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


C# Repository.UpdateRepository方法代码示例

本文整理汇总了C#中LibGit2Sharp.Repository.UpdateRepository方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.UpdateRepository方法的具体用法?C# Repository.UpdateRepository怎么用?C# Repository.UpdateRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibGit2Sharp.Repository的用法示例。


在下文中一共展示了Repository.UpdateRepository方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateSubmodules

        public static void UpdateSubmodules(this IRepository git)
        {
            foreach (var submodule in git.Submodules)
            {
                var subrepoPath = Path.Combine(git.Info.WorkingDirectory, submodule.Path);
                if (!Repository.IsValid(subrepoPath))
                {
                    Directory.Delete(subrepoPath, true);
                    Repository.Clone(submodule.Url, subrepoPath);
                }

                using (var subrepo = new Repository(subrepoPath))
                {
                    subrepo.UpdateRepository(submodule.HeadCommitId.Sha);
                }
            }
        }
开发者ID:ap0110,项目名称:citizenmp-server-updater,代码行数:17,代码来源:RepositoryExtensions.cs

示例2: Main

        private static int Main(string[] args)
        {
            var monoRun = RunWithMonoConfiguration(args);
            if (monoRun.Item1)
            {
                // The main stuff already ran in a subprocess
                return monoRun.Item2;
            }

            // Parse cmdline arguments
            var options = new CommandLineOptions();
            //args = args.DefaultIfEmpty("--help").ToArray();
            if (!Parser.Default.ParseArgumentsStrict(args, options, () => { Environment.Exit(-2); }))
            {
                return -2;
            }

            if (options.ShowVersion)
            {
                var version =
                    Regex.Match(
                        Assembly.GetExecutingAssembly()
                            .GetCustomAttributes(typeof (AssemblyInformationalVersionAttribute), false)
                            .OfType<AssemblyInformationalVersionAttribute>().First().InformationalVersion,
                        @"^(?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<revision>[0-9]+)(\-(?<prerelease>[A-z0-9\.]+))?(\+(?<meta>.+?))?$");

                var meta = new Queue<string>(version.Groups["meta"].Value.Split('.'));
                while (meta.Any() && meta.First() != "Branch")
                {
                    meta.Dequeue();
                }

                var metaDict = new Dictionary<string, string>();
                while (meta.Any())
                {
                    var name = meta.Dequeue();
                    var value = meta.Dequeue();
                    if (meta.Any() && char.IsDigit(meta.First().First()))
                    {
                        value += "." + meta.Dequeue();
                    }
                    metaDict.Add(name, value);
                }

                Console.WriteLine("{0}.{1}.{2}{3}{4}",
                    version.Groups["major"].Value,
                    version.Groups["minor"].Value,
                    version.Groups["revision"].Value,
                    version.Groups["prerelease"].Success ? "-" + version.Groups["prerelease"].Value : "",
                    metaDict.Any() ? " (" + metaDict["Sha"].Substring(0, 7) + ")" : "");
                return 0;
            }

            if (string.IsNullOrEmpty(options.OutputPath))
            {
                Console.Error.WriteLine("ERROR: No output directory given.");
                Console.Write(options.GetUsage());
                return -2;
            }

            var sourceDirectory = new DirectoryInfo(options.SourceDir);
            var dataSourceDirectory = sourceDirectory
                // Who knows if this directory will somewhen cease to exist...
                .CreateSubdirectory("CitizenMP.Server")
                .CreateSubdirectory("data");
            var outputDirectory = new DirectoryInfo(options.OutputPath);
            var binOutputDirectory = new DirectoryInfo(Path.Combine(outputDirectory.FullName, "bin"));

            // Do we even have a copy or do we need to clone?
            if (!Repository.IsValid(sourceDirectory.FullName))
            {
                if (sourceDirectory.Exists)
                {
                    Console.WriteLine("Deleting source code folder...");
                    sourceDirectory.Delete(true);
                }

                Console.WriteLine("Cloning source code repository...");
                Repository.Clone("http://tohjo.ez.lv/citidev/citizenmp-server.git", sourceDirectory.FullName);
            }
            else
            {
                // Update working dir
                Console.WriteLine("Updating source code...");
                using (var git = new Repository(sourceDirectory.FullName))
                {
                    //git.Network.Pull(GitSignature, new PullOptions());
                    git.UpdateRepository("HEAD");
                }
            }

            // Check if we need to update by parsing AssemblyConfigurationAttribute in server assembly.
            // Should have a space-separated segment saying "CommitHash=<commit hash here>".
            if (binOutputDirectory.Exists)
            {
                var serverBins = binOutputDirectory
                    .EnumerateFiles("*Server.exe", SearchOption.TopDirectoryOnly)
                    .ToArray();
                if (serverBins.Any())
                {
//.........这里部分代码省略.........
开发者ID:ap0110,项目名称:citizenmp-server-updater,代码行数:101,代码来源:Program.cs


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