Пример #1
0
        internal static async Task <int> Main(string[] args)
        {
            MiniDump.DumpMessage += MiniDump_DumpMessage;
            _ = Assembly.GetEntryAssembly().EntryPoint.GetCustomAttributes <MiniDumpAttribute>(false);
            GitInformation.ApplyAssemblyAttributes(typeof(Program).Assembly);
            var cmd = new RootCommand
            {
                new Option("--version", "Shows the version of this command-line program."),
                new Command("build", "builds a changelog or news file from any *.master file in the current or sub directory.")
                {
                }.WithHandler(nameof(BuildCommandHandler)),
                new Command("new", string.Empty)
                {
                    new Command("release", "Creates a new pending release folder and imports it in the *.master file in the current or sub directory.")
                    {
                        new Argument <string>("release", "The new release version."),
                    }.WithHandler(nameof(NewReleaseCommandHandler)),
                    new Command("entry", "Creates a new entry file for the current pending release.")
                    {
                        new Argument <string>("content", "The content to add to the new entry."),
                    }.WithHandler(nameof(NewEntryCommandHandler)),
                },
                new Command("finalize", string.Empty)
                {
                    new Command("release", "Finalizes a pending release to a section file.")
                    {
                    }.WithHandler(nameof(FinalizeReleaseCommandHandler)),
                },
            }.WithHandler(nameof(GlobalCommandHandler));

            return(await cmd.InvokeAsync(args));
        }
Пример #2
0
        public void Prepare_LogMessagesWithoutTagsAndCommits_ShouldThrowException()
        {
            var timeMessagePreparer = MessagePrepareFactory.GetMessagePreparer();
            var gitInformation      = new GitInformation(null, GitSortStrategy.Reverse | GitSortStrategy.Time);

            gitInformation.Repository = new GitRepository(null, null, GitSortStrategy.None);
            var logs = timeMessagePreparer.PrepareMessages(gitInformation).ToList();
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GitInformationAttribute"/> class.
        /// </summary>
        /// <param name="headdesc">
        /// The head description of the git repository to the assembly.
        /// </param>
        /// <param name="commit">
        /// The commit to the git repository to the assembly.
        /// </param>
        /// <param name="branchname">
        /// The branch name to the git repository to the assembly.
        /// </param>
        /// <param name="assemblyType">
        /// The <see langword="type"/> of the <see langword="assembly"/> <see langword="this"/> attribute <see langword="is"/> applied to.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown when <paramref name="assemblyType"/> is <see langword="null"/>.
        /// </exception>
        public GitInformationAttribute(string headdesc, string commit, string branchname, Type assemblyType /*object assembly*/)
        {
            if (assemblyType == null)
            {
                throw new ArgumentNullException(nameof(assemblyType));
            }

            GitInformation.ApplyAssemblyAttributes(typeof(GitInformation).Assembly);
            _ = new GitInformation(headdesc, commit, branchname, assemblyType.Assembly);
        }
Пример #4
0
        public void Prepare_LogMessagesWithEmptyTagsAndCommits_ShouldBeOk()
        {
            var timeMessagePreparer = MessagePrepareFactory.GetMessagePreparer();
            var gitInformation      = new GitInformation(null, GitSortStrategy.Reverse | GitSortStrategy.Time);

            gitInformation.Repository = new GitRepository(new List <GitVersionTag>(), new List <GitCommit>(), GitSortStrategy.None);
            var logs = timeMessagePreparer.PrepareMessages(gitInformation).ToList();

            Assert.IsNotNull(logs);
            Assert.AreEqual(0, logs.Count);
        }
        public void ExtractionOfWithoutAnyTags(string value)
        {
            // Arrange
            var gitInformation = new GitInformation();

            // Act
            gitInformation.SetTagName(value);

            // Assert
            Assert.Empty(gitInformation.TagsName);
        }
        private string CommentFormatter(GitInformation item)
        {
            var result = item.Comment;

            result = result.Replace(Separator, ',');
            if (result.StartsWith('-'))
            {
                result = $"'{result}";
            }
            return(result);
        }
        public void ExtractionOfTheComment(string expectedJiraTicket, string expectedComment, string message)
        {
            // Arrange
            var gitInformation = new GitInformation();

            // Act
            gitInformation.SetComment(message);

            // Assert
            Assert.Equal(expectedJiraTicket, gitInformation.JiraTicket);
            Assert.Equal(expectedComment, gitInformation.Comment);
        }
        public void ExtractionOfOneTagName(string expected, string value)
        {
            // Arrange
            var gitInformation = new GitInformation();

            // Act
            gitInformation.SetTagName(value);

            // Assert
            Assert.Single(gitInformation.TagsName);
            Assert.Equal(expected, gitInformation.TagsName[0]);
        }
Пример #9
0
        private GitInformation ManageTag(List <string> informations, GitInformation newEntry, ref string currentTag)
        {
            if (string.IsNullOrEmpty(informations[0]))
            {
                newEntry.FullTagName = currentTag;
                newEntry.TagsName    = currentTag.Split(',').ToList();
            }
            else
            {
                newEntry.SetTagName(informations[0]);
                currentTag = newEntry.TagsNameFormatted;
            }

            return(newEntry);
        }
        public void ExtractionOfWithMoreThanOne(string value, params string[] expectations)
        {
            // Arrange
            var gitInformation = new GitInformation();

            // Act
            gitInformation.SetTagName(value);

            // Assert
            Assert.Equal(expectations.Length, gitInformation.TagsName.Count);
            foreach (var expected in expectations)
            {
                Assert.Contains(expected, gitInformation.TagsName);
            }
        }
Пример #11
0
        internal static int GlobalCommandHandler(bool version, IConsole console)
        {
            var inst = GitInformation.GetAssemblyInstance(typeof(Program));

            if (!inst.IsMain || inst.IsDirty)
            {
                console.Out.WriteLine(newsmakeResources.Resources.Commands_Potentially_Unstable_Build);
            }

            if (version)
            {
                console.Out.WriteLine(string.Format(CultureInfo.InvariantCulture, newsmakeResources.Resources.CommandParser_ShowHelp_Version, Assembly.GetEntryAssembly().GetName().Version));
            }

            return(0);
        }
Пример #12
0
        internal static int BuildCommandHandler(IConsole console)
        {
            var inst = GitInformation.GetAssemblyInstance(typeof(Program));

            if (!inst.IsMain || inst.IsDirty)
            {
                console.Out.WriteLine(newsmakeResources.Resources.Commands_Potentially_Unstable_Build);
            }

            var ext               = ".master";
            var project_name      = string.Empty;
            var outputfile_name   = string.Empty;
            var tabs              = true;
            var devmode           = false;
            var delete_files      = true;
            var first_import      = true;
            var found_master_file = false;
            var output_format_md  = false;
            var section_data      = new List <string>();

            foreach (var p in Directory.GetFiles(Directory.GetCurrentDirectory(), "*", SearchOption.AllDirectories))
            {
                if (p.EndsWith(ext, StringComparison.Ordinal))
                {
                    found_master_file = true;
                    console.Out.WriteLine(string.Format(CultureInfo.InvariantCulture, newsmakeResources.Resources.Commands_BuildCommand_Processing, p));

                    // set the current directory to p.
                    Directory.SetCurrentDirectory(new FileInfo(p).Directory.FullName);
                    var master_file = File.ReadAllLines(p);
                    for (var i = 0; i < master_file.Length; i++)
                    {
                        // a hack to make this all work as intended.
                        var line = master_file[i];
                        if (!line.Contains("# ", StringComparison.Ordinal))
                        {
                            do
                            {
                                // get environment variable name.
                                // find the "$(" and make a substring then find the first ")"
                                var env_open  = line.IndexOf("$(", StringComparison.Ordinal);
                                var env_close = line.IndexOf(")", StringComparison.Ordinal);
                                if (env_open != env_close)
                                {
                                    var envvar = line[(env_open + 2)..env_close];
Пример #13
0
        internal static int Main(string[] args)
        {
            MiniDump.DumpMessage += MiniDump_DumpMessage;

            // MiniDump.DumpFailed += MiniDump_DumpFailed;
            GitInformation.ApplyAssemblyAttributes(typeof(Els_kom_Main).Assembly);

            // _ = Assembly.GetEntryAssembly().GetCustomAttributes(false);
            KOMManager.MessageEvent        += KOMManager_MessageEvent;
            PluginUpdateCheck.MessageEvent += PluginUpdateCheck_MessageEvent;

            // have to pass in string to this as otherwise it will not compile.
            GenericPluginLoader <string> .PluginLoaderMessage += GenericPluginLoader_PluginLoaderMessage;

            // execute our attribute.
            // uncomment if the attribute is on the assembly:
            // Assembly.GetEntryAssembly().GetCustomAttributes(false);
            // or:
            // typeof(TheClassWithTheAttribute).Assembly.GetCustomAttributes(false);
            // uncomment if the attribute is on the class:
            // Assembly.GetEntryAssembly().EntryPoint.ReflectedType.GetCustomAttributes(false);
            // or:
            // typeof(TheClassWithTheAttribute).GetCustomAttributes(false);
            // uncomment if you want the attribute on the class:
            // Assembly.GetEntryAssembly().EntryPoint.GetCustomAttributes(false);
            // or:
            // typeof(TheClassWithTheAttribute).GetMethod(nameof(Main), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static)?.GetCustomAttributes(false);
            if ((args.Length - 1) > -1)
            {
                ReleasePackaging.PackageRelease(args);
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                using (var mainForm = new MainForm())
                {
                    Application.Run(mainForm);
                }
            }

            return(0);
        }
        public IEnumerable <LogDescriptor> PrepareMessages(GitInformation gitInformation)
        {
            Guard.ArgumentNotNull(gitInformation, nameof(gitInformation));

            var tagRanges = gitInformation.Tags;

            foreach (var range in tagRanges)
            {
                Trace.TraceInformation("Handling tag-range {0} to {1}", range.VersionFrom, range.VersionTo);
                var commits = gitInformation.GetCommitsFromTagTo(range.VersionFrom, range.FromToAreEqual ? null : range.VersionTo);
                foreach (var commit in commits)
                {
                    Trace.TraceInformation("Add commit {0} to tag {1}", commit.Message, range.VersionFrom);
                    yield return(new LogDescriptor()
                    {
                        Hash = commit.Hash, Message = commit.Message, Tag = range.VersionFrom
                    });
                }
            }
        }
Пример #15
0
        private static void HandleOptions(Options options)
        {
            string versionFormat = null;

            if (ConfigurationManager.AppSettings.AllKeys.Contains("VersionFormat"))
            {
                versionFormat = ConfigurationManager.AppSettings["VersionFormat"];
            }

            if (!options.Verbose)
            {
                Trace.Listeners.Clear();
            }

            GitInformation info = new GitInformation(options.RepositoryPath, GitSortStrategy.Reverse | GitSortStrategy.Time);

            if (!string.IsNullOrEmpty(options.Tag))
            {
                Version specificVersion;
                if (Version.TryParse(options.Tag, out specificVersion))
                {
                    info.SpecificTag = specificVersion;
                }
            }

            info.GetRepositoryInformation();

            var preparer = MessagePrepareFactory.GetMessagePreparer();
            var logs     = preparer.PrepareMessages(info).ToList();

            var ticketIntegrator = TicketingFactory.GetTicketingIntegrator(options.TicketingTool);
            var tickets          = ticketIntegrator.CombineLogsWithTicketing(logs);

            var exporter = LogExporterFactory.GetLogExporter("markdown");
            var val      = exporter.GetExportValue(tickets, options.LinkTickets, versionFormat);

            File.WriteAllText(options.ExportFileName, val);
        }
Пример #16
0
        internal static int Main(string[] args)
        {
            MiniDump.DumpMessage += MiniDump_DumpMessage;
            GitInformation.ApplyAssemblyAttributes(typeof(Els_kom_Main).Assembly);
            KOMManager.MessageEvent        += KOMManager_MessageEvent;
            PluginUpdateCheck.MessageEvent += PluginUpdateCheck_MessageEvent;

            // have to pass in string to this as otherwise it will not compile.
            GenericPluginLoader <string> .PluginLoaderMessage += GenericPluginLoader_PluginLoaderMessage;
            if ((args.Length - 1) > -1)
            {
                ReleasePackaging.PackageRelease(args);
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                using var mainForm = new MainForm();
                Application.Run(mainForm);
            }

            return(0);
        }
Пример #17
0
        public IList <GitInformation> Convert(string logs)
        {
            var currentTag = "untagged-version";
            var result     = new List <GitInformation>();

            foreach (string logLine in logs.Split(Configuration.EndLineSplitCharacter, StringSplitOptions.RemoveEmptyEntries))
            {
                var informations = logLine.Split(Configuration.SplitCharacter).ToList();
                var newEntry     = new GitInformation
                {
                    CommitHash  = informations[2],
                    CommitDate  = DateTime.Parse(informations[3]),
                    AuthorName  = informations[4],
                    AuthorEmail = informations[5]
                };
                newEntry = ManageTag(informations, newEntry, ref currentTag);
                newEntry.SetComment(informations[1]);
                if (!newEntry.HasError)
                {
                    result.Add(newEntry);
                }
            }
            return(result);
        }
Пример #18
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.Hide();
            var closing = false;

            if (!Directory.Exists(Application.StartupPath + "\\koms"))
            {
                _ = Directory.CreateDirectory(Application.StartupPath + "\\koms");
            }

            if (ExecutionManager.IsElsKomRunning() == true)
            {
                _       = MessageManager.ShowError("Sorry, Only 1 Instance is allowed at a time.", "Error!", false);
                closing = true;
            }
            else
            {
                SettingsFile.Settingsxml = new XmlObject(SettingsFile.Path, "<Settings></Settings>");
                this.elsDir = SettingsFile.Settingsxml?.TryRead("ElsDir");
                if (this.elsDir.Length < 1)
                {
                    _ = MessageManager.ShowInfo("Welcome to Els_kom." + Environment.NewLine + "Now your fist step is to Configure Els_kom to the path that you have installed Elsword to and then you can Use the test Mods and the executing of the Launcher features. It will only take less than 1~3 minutes tops." + Environment.NewLine + "Also if you encounter any bugs or other things take a look at the Issue Tracker.", "Welcome!", false);

                    // avoids an issue where more than 1 settings form can be opened at the same time.
                    if (this.settingsfrm == null && this.aboutfrm == null)
                    {
                        this.settingsfrm = new SettingsForm();
                        _ = this.settingsfrm.ShowDialog();
                        this.settingsfrm.Dispose();
                        this.settingsfrm = null;
                    }
                }

                if (!int.TryParse(SettingsFile.Settingsxml?.TryRead("SaveToZip"), out var saveToZip1))
                {
                    // do nothing to silence a compile error.
                }

                if (!int.TryParse(SettingsFile.Settingsxml?.TryRead("LoadPDB"), out var loadPDB1))
                {
                    // do nothing to silence a compile error.
                }

                var komplugins = new GenericPluginLoader <IKomPlugin>().LoadPlugins("plugins", Convert.ToBoolean(saveToZip1), Convert.ToBoolean(loadPDB1));
                KOMManager.Komplugins.AddRange(komplugins);
                var callbackplugins = new GenericPluginLoader <ICallbackPlugin>().LoadPlugins("plugins", Convert.ToBoolean(saveToZip1), Convert.ToBoolean(loadPDB1));
                KOMManager.Callbackplugins.AddRange(callbackplugins);
                if (!GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsMaster ?? false)
                {
                    _ = MessageManager.ShowInfo("This branch is not the master branch, meaning this is a feature branch to test changes. When finished please pull request them for the possibility of them getting merged into master.", "Info!", Convert.ToBoolean(Convert.ToInt32(SettingsFile.Settingsxml?.TryRead("UseNotifications") != string.Empty ? SettingsFile.Settingsxml?.TryRead("UseNotifications") : "0")));
                }

                if (GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsDirty ?? false)
                {
                    var resp = MessageBox.Show("This build was compiled with Uncommitted changes. As a result, this build might be unstable. Are you sure you want to run this build to test some changes to the code?", "Info!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (resp == DialogResult.No)
                    {
                        closing = true;
                    }
                }
            }

            if (!closing)
            {
                this.MessageManager1.Icon    = this.Icon;
                this.MessageManager1.Text    = this.Text;
                this.MessageManager1.Visible = true;
                var pluginTypes = new List <Type>();
                foreach (var callbackplugin in KOMManager.Callbackplugins)
                {
                    pluginTypes.Add(callbackplugin.GetType());
                }

                foreach (var komplugin in KOMManager.Komplugins)
                {
                    pluginTypes.Add(komplugin.GetType());
                }

                PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                    SettingsFile.Settingsxml?.TryRead("Sources", "Source", null),
                    pluginTypes);
                foreach (var pluginUpdateCheck in PluginUpdateChecks)
                {
                    // discard result.
                    var result = pluginUpdateCheck.ShowMessage;
                }

                this.Show();
                this.Activate();
            }
            else
            {
                SettingsFile.Settingsxml = null;
                this.aboutfrm?.Close();
                this.settingsfrm?.Close();
                this.Close();
            }
        }
Пример #19
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.Hide();
            this.packToolStripMenuItem.Image     = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.archive, ShareXResources.Theme.TextColor);
            this.unpackToolStripMenuItem.Image   = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.unarchive, ShareXResources.Theme.TextColor);
            this.testModsToolStripMenuItem.Image = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.vial_solid, ShareXResources.Theme.TextColor);
            this.launcherToolStripMenuItem.Image = NativeMethods.ConvertSVGTo16x16Image(Properties.Resources.launch, ShareXResources.Theme.TextColor);
            this.exitToolStripMenuItem.Image     = NativeMethods.GetNativeMenuItemImage(new IntPtr(NativeMethods.HBMMENU_POPUP_CLOSE), true);
            var closing = false;

            if (!Directory.Exists(Application.StartupPath + "\\koms"))
            {
                _ = Directory.CreateDirectory(Application.StartupPath + "\\koms");
            }

            if (ExecutionManager.IsElsKomRunning())
            {
                _       = MessageManager.ShowError("Sorry, Only 1 Instance is allowed at a time.", "Error!", false);
                closing = true;
            }
            else
            {
                this.elsDir = SettingsFile.SettingsJson.ElsDir;
                if (this.elsDir.Length < 1)
                {
                    _ = MessageManager.ShowInfo($"Welcome to Els_kom.{Environment.NewLine}Now your fist step is to Configure Els_kom to the path that you have installed Elsword to and then you can Use the test Mods and the executing of the Launcher features. It will only take less than 1~3 minutes tops.{Environment.NewLine}Also if you encounter any bugs or other things take a look at the Issue Tracker.", "Welcome!", false);

                    // avoids an issue where more than 1 settings form can be opened at the same time.
                    if (this.settingsfrm == null && this.aboutfrm == null)
                    {
                        using (this.settingsfrm = new SettingsForm())
                        {
                            _ = this.settingsfrm.ShowDialog();
                        }

                        this.settingsfrm = null;
                    }
                }

                var komplugins = new GenericPluginLoader <IKomPlugin>().LoadPlugins("plugins", out var domains1, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Komplugins.AddRange(komplugins);
                var callbackplugins = new GenericPluginLoader <ICallbackPlugin>().LoadPlugins("plugins", out var domains2, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Callbackplugins.AddRange(callbackplugins);
                var encryptionplugins = new GenericPluginLoader <IEncryptionPlugin>().LoadPlugins("plugins", out var domains3, Convert.ToBoolean(SettingsFile.SettingsJson.SaveToZip));
                KOMManager.Encryptionplugins.AddRange(encryptionplugins);
#if NET5_0_OR_GREATER
                Contexts.AddRange(domains1);
                Contexts.AddRange(domains2);
                Contexts.AddRange(domains3);
#else
                Domains.AddRange(domains1);
                Domains.AddRange(domains2);
                Domains.AddRange(domains3);
#endif
                if (!GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsMain ?? false)
                {
                    _ = MessageManager.ShowInfo("This branch is not the main branch, meaning this is a feature branch to test changes. When finished please pull request them for the possibility of them getting merged into main.", "Info!", Convert.ToBoolean(SettingsFile.SettingsJson.UseNotifications));
                }

                if (GitInformation.GetAssemblyInstance(typeof(Els_kom_Main))?.IsDirty ?? false)
                {
                    var resp = MessageBox.Show("This build was compiled with Uncommitted changes. As a result, this build might be unstable. Are you sure you want to run this build to test some changes to the code?", "Info!", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (resp == DialogResult.No)
                    {
                        closing = true;
                    }
                }
            }

            if (!closing)
            {
                MessageManager.Icon = this.Icon;
                MessageManager.Text = this.Text;
                var pluginTypes = new List <Type>();
                pluginTypes.AddRange(KOMManager.Callbackplugins.Select((x) => x.GetType()));
                pluginTypes.AddRange(KOMManager.Komplugins.Select((x) => x.GetType()));
                pluginTypes.AddRange(KOMManager.Encryptionplugins.Select((x) => x.GetType()));
                PluginUpdateChecks = PluginUpdateCheck.CheckForUpdates(
                    SettingsFile.SettingsJson.Sources.Source.ToArray(),
                    pluginTypes,
                    Els_kom_Main.ServiceProvider);
                foreach (var pluginUpdateCheck in PluginUpdateChecks)
                {
                    // discard result.
                    _ = pluginUpdateCheck.ShowMessage;
                }

                MessageManager.Visible = true;
                this.Show();
                this.Activate();
            }
            else
            {
                SettingsFile.SettingsJson = null;
                this.aboutfrm?.Close();
                this.settingsfrm?.Close();
                this.Close();
            }
        }
 private string FormatterLowDetailled(GitInformation item)
 {
     return($"{item.JiraTicket}{Separator}{ingenicoJiraBaseUrl}{item.JiraTicket}{Separator}{item.AuthorName}");
 }