Esempio n. 1
0
        public void testing_SimpleGitRepositoryInfo_on_this_repository()
        {
            var info = SimpleRepositoryInfo.LoadFromPath(new ConsoleLogger(), TestHelper.SolutionFolder, (logger, hasRepoXml, opt) =>
            {
                logger.Info("Ignoring DirtyWorkingFolder check.");
                opt.IgnoreDirtyWorkingFolder = true;
            });

            Console.WriteLine("This repo's SemVer: {0}", info.SafeSemVersion);
        }
Esempio n. 2
0
        public void testing_SimpleGitRepositoryInfo_on_other_repository()
        {
            var info = SimpleRepositoryInfo.LoadFromPath(new ConsoleLogger(), @"C:\Dev\CK-Database\CK-SqlServer-Parser");

            Console.WriteLine("This repo's SemVer: {0}", info.SemVer);
        }
Esempio n. 3
0
        public void testing_SimpleGitRepositoryInfo_on_this_repository()
        {
            var info = SimpleRepositoryInfo.LoadFromPath(new ConsoleLogger(), TestHelper.SolutionFolder);

            Console.WriteLine("This repo's SemVer: {0}", info.SemVer);
        }
Esempio n. 4
0
        public void testing_SimpleGitRepositoryInfo_on_other_repository()
        {
            var info = SimpleRepositoryInfo.LoadFromPath(new ConsoleLogger(), @"C:\Dev\CK\CK-Core-Projects\CK-Text");

            Console.WriteLine("This repo's SemVer: {0}", info.SafeSemVersion);
        }
Esempio n. 5
0
        static int Main(string[] args)
        {
            try
            {
                var app = new CommandLineApplication();
                app.Name        = "sgv";
                app.Description = "SimpleGitVersion commands.";
                app.HelpOption("-?|-h|--help");
                app.VersionOption("--version", GetVersion, GetInformationalVersion);
                var optVerbose = app.Option("-v|--verbose", "Verbose output", CommandOptionType.NoValue);

                app.Command("info", c =>
                {
                    c.Description     = "Display SimpleGitVersion information from Git repository.";
                    var optionProject = c.Option("-p|--project <PATH>", "Path to a project, solution or any path under the solution directory, default is current directory", CommandOptionType.SingleValue);
                    c.HelpOption("-?|-h|--help");

                    c.OnExecute(() =>
                    {
                        ConsoleLoggerAdapter logger = new ConsoleLoggerAdapter(true);
                        string path = optionProject.Value() ?? Directory.GetCurrentDirectory();
                        SimpleRepositoryInfo info = SimpleRepositoryInfo.LoadFromPath(logger, path, (log, hasRepoXml, options) =>
                        {
                            options.IgnoreDirtyWorkingFolder = true;
                        });
                        return(0);
                    });
                });

                app.Command("prebuild", c =>
                {
                    c.Description     = "Creates or updates Properties/SGVVersionInfo.cs files from Git repository.";
                    var optionProject = c.Option("-p|--project <PATH>", "Path to project, default is current directory", CommandOptionType.SingleValue);
                    c.HelpOption("-?|-h|--help");

                    c.OnExecute(() =>
                    {
                        ConsoleLoggerAdapter logger = new ConsoleLoggerAdapter(optVerbose.HasValue());
                        string path = optionProject.Value() ?? Directory.GetCurrentDirectory();
                        var ctx     = new DNXSolution(path, logger);
                        if (ctx.IsValid)
                        {
                            var project = ctx.FindFromPath(path);
                            if (project != null)
                            {
                                project.CreateOrUpdateSGVVersionInfoFile();
                            }
                            else
                            {
                                logger.Warn("Project not found.");
                            }
                        }
                        return(0);
                    });
                });

                app.Command("update", c =>
                {
                    c.Description     = "Updates version properties in project.json files based on Git repository.";
                    var optionProject = c.Option("-p|--project <PATH>", "Path to project, default is current directory", CommandOptionType.SingleValue);
                    c.HelpOption("-?|-h|--help");

                    c.OnExecute(() =>
                    {
                        ConsoleLoggerAdapter logger = new ConsoleLoggerAdapter(optVerbose.HasValue());
                        string path = optionProject.Value() ?? Directory.GetCurrentDirectory();
                        var ctx     = new DNXSolution(path, logger);
                        if (ctx.IsValid)
                        {
                            ctx.UpdateProjectFiles();
                        }
                        return(0);
                    });
                });

                app.Command("restore", c =>
                {
                    c.Description     = "Restores project.json files that differ only by version properties for this solution.";
                    var optionProject = c.Option("-p|--project <PATH>", "Path to project, default is current directory", CommandOptionType.SingleValue);
                    c.HelpOption("-?|-h|--help");

                    c.OnExecute(() =>
                    {
                        ConsoleLoggerAdapter logger = new ConsoleLoggerAdapter(optVerbose.HasValue());
                        string path = optionProject.Value() ?? Directory.GetCurrentDirectory();
                        var ctx     = new DNXSolution(path, logger);
                        if (ctx.IsValid)
                        {
                            ctx.RestoreProjectFilesFromGitThatDifferOnlyByVersion();
                        }
                        return(0);
                    });
                });

                // Show help information if no subcommand/option was specified.
                app.OnExecute(() =>
                {
                    app.ShowHelp();
                    return(2);
                });

                return(app.Execute(args));
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error: {0}", exception.Message);
                return(1);
            }
        }