Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

            Application.EnableVisualStyles();

            //Prevent crash that occurs when this dll is not present
            if (!File.Exists(Application.StartupPath + "/Octokit.dll"))
            {
                MessageBox.Show("Unable to find Octokit.dll.");
                return;
            }

            bool somethingDone = true;
            Task t;

            if (args.Length > 0)
            {
                switch (args[0])
                {
                case "-r":     //overwrite
                    t = Updater.CheckUpdate(true);
                    t.Wait();
                    break;

                case "-n":     // Update in new folder
                    t = Updater.CheckUpdate(false);
                    t.Wait();
                    break;

                case "-bu":     //BrawlCrate update call
                    t = Updater.CheckUpdate(args[1] != "0", args[2], args[3] != "0", args[4], args[5] != "0",
                                            args[6] != "0", args[7] != "0");
                    t.Wait();
                    break;

                case "-buc":     //BrawlCrate Canary update call
                    t = Updater.CheckCanaryUpdate(args.Length > 1 ? args[1] : null,
                                                  args.Length > 2 && args[2] != "0", args[3] != "0", args[4] != "0");
                    t.Wait();
                    break;

                case "-bi":     //BrawlCrate issue call
                    t = IssueReporter.CreateIssue(args[1], args[2], args[3], args[4], args[5]);
                    t.Wait();
                    break;

                case "-bcommitTime":     //Called on build to ensure time is saved
                    string t4arg1 = args.Length > 1 ? args[1] : null;
                    string t4arg2 = args.Length > 2 ? args[2] : null;
                    string t4arg3 = args.Length > 3 ? args[3] : null;
                    string t4arg4 = args.Length > 4 ? args[4] : null;

                    t = Updater.WriteCanaryTime(t4arg1, t4arg2, t4arg3, t4arg4);
                    t.Wait();
                    break;

                case "-dlCanary":     // Force download the latest Canary build
                    Updater.SetCanaryActive();
                    t = Updater.CheckCanaryUpdate(args.Length > 1 ? args[1] : null, false, true, false);
                    t.Wait();
                    break;

                case "-dlStable":     // Force download the latest Stable build
                    Updater.SetCanaryInactive();
                    t = Updater.ForceDownloadStable(args.Length > 1 ? args[1] : null);
                    t.Wait();
                    break;

                case "-dlDoc":     // Force download the latest Documentation build
                    t = Updater.ForceDownloadDocumentation();
                    t.Wait();
                    break;

                case "-canarylog":     // Show changelog for canary
                    t = Updater.ShowCanaryChangelog();
                    t.Wait();
                    break;

                case "-canaryOn":     // Activate canary build
                    Updater.SetCanaryActive();
                    break;

                case "-canaryOff":
                    Updater.SetCanaryInactive();
                    break;

                case "-killAll":
                    t = Updater.KillOpenWindows();
                    t.Wait();
                    break;

                case "-apiUpdate":
                    t = Updater.BrawlAPICheckUpdates(args.Length > 1 && args[1] == "1");
                    t.Wait();
                    break;

                case "-apiInstall":
                    t = Updater.BrawlAPIInstallUpdate(args[1], args[2], args.Length > 3 && args[3] == "1");
                    t.Wait();
                    break;

                case "-apiUninstall":
                    Updater.BrawlAPIUninstall(args[1], args[2], args.Length > 3 && args[3] == "1");
                    break;

                default:
                    somethingDone = false;
                    break;
                }
            }
            else if (args.Length == 0)
            {
#if CANARY
                t = Updater.CheckCanaryUpdate("", true, false, true);
#else
                t = Updater.CheckUpdate(true);
#endif
                t.Wait();
            }

            if (!somethingDone)
            {
                Console.WriteLine(Usage);
            }
        }
Exemplo n.º 2
0
        public static async Task CreateIssue(
            string TagName,
            string ExceptionMessage,
            string StackTrace,
            string Title,
            string Description)
        {
            if (File.Exists(Updater.AppPath + "\\Canary\\Active") &&
                !Updater.currentRepo.Equals(Updater.mainRepo, StringComparison.OrdinalIgnoreCase))
            {
                MessageBox.Show(
                    "Issue reporter does not allow reporting issues from forks. Please contact the owner of the repository to report your issue.");
                return;
            }

            try
            {
                Issue        x      = null;
                Credentials  cr     = new Credentials(Encoding.Default.GetString(Program.RawData));
                GitHubClient github = new GitHubClient(new ProductHeaderValue("BrawlCrate"))
                {
                    Credentials = cr
                };
                IReadOnlyList <Issue> issues = null;
                if (!TagName.ToLower().Contains("canary"))
                {
                    IReadOnlyList <Release> releases;
                    try
                    {
                        releases = await github.Repository.Release.GetAll("soopercool101", "BrawlCrate");

                        // Remove all pre-release (Documentation) versions from the list
                        releases = releases.Where(r => !r.Prerelease).ToList();

                        issues = await github.Issue.GetAllForRepository("BrawlCrate", "BrawlCrateIssues");
                    }
                    catch (HttpRequestException)
                    {
                        MessageBox.Show("Unable to connect to the internet.");
                        return;
                    }

                    if (releases.Count > 0 && releases[0].TagName != TagName)
                    {
                        //This build's version tag does not match the latest release's tag on the repository.
                        //This issue may have been fixed by now. Tell the user to update to be allowed to submit reports.

                        DialogResult UpdateResult =
                            MessageBox.Show(
                                releases[0].Name +
                                " is available!\nYou cannot submit bug reports using an older version of the program.\nUpdate now?",
                                "An update is available", MessageBoxButtons.YesNo);
                        if (UpdateResult == DialogResult.Yes)
                        {
                            Task t = Updater.ForceDownloadStable("");
                            t.Wait();
                        }

                        return;
                    }
                }

                TagName += $" {Updater.platform}";
                bool found = false;
                if (issues != null && !string.IsNullOrEmpty(StackTrace))
                {
                    foreach (Issue i in issues.Where(i => i.State == ItemState.Open))
                    {
                        string desc = i.Body;
                        if (desc.Contains(StackTrace) &&
                            desc.Contains(ExceptionMessage))
                        {
                            found = true;
                            IssueUpdate update = i.ToUpdate();

                            update.Body =
                                Title +
                                Environment.NewLine +
                                Description +
                                Environment.NewLine +
                                Environment.NewLine +
                                TagName +
                                Environment.NewLine +
                                i.Body;

                            x = await github.Issue.Update("BrawlCrate", "BrawlCrateIssues", i.Number, update);
                        }
                    }
                }

                if (!found)
                {
                    NewIssue issue = new NewIssue(Title)
                    {
                        Body =
                            Description +
                            Environment.NewLine +
                            Environment.NewLine +
                            TagName +
                            Environment.NewLine +
                            "```" +
                            Environment.NewLine +
                            ExceptionMessage +
                            Environment.NewLine +
                            StackTrace +
                            Environment.NewLine +
                            "```"
                    };
                    x = await github.Issue.Create("BrawlCrate", "BrawlCrateIssues", issue);
                }

                if (x != null)
                {
                    if (MessageBox.Show(
                            $"Your issue can be found at {x.HtmlUrl}. Please add any clarification on the issue there.\n\nWould you like to open this webpage in your browser?",
                            "Issue Reported", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        Process issue = Process.Start(new ProcessStartInfo
                        {
                            FileName = x.HtmlUrl
                        });
                    }
                }
            }
            catch
            {
                MessageBox.Show("The application was unable to retrieve permission to send this issue.");
            }
        }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;

            Application.EnableVisualStyles();

            //Prevent crash that occurs when this dll is not present
            if (!File.Exists(Application.StartupPath + "/Octokit.dll"))
            {
                MessageBox.Show("Unable to find Octokit.dll.");
                return;
            }

            bool somethingDone = false;

            if (args.Length > 0)
            {
                switch (args[0])
                {
                case "-r":     //overwrite
                    somethingDone = true;
                    Task t = Updater.CheckUpdate(true);
                    t.Wait();
                    break;

                case "-n":     // Update in new folder
                    somethingDone = true;
                    Task t1 = Updater.CheckUpdate(false);
                    t1.Wait();
                    break;

                case "-bu":     //BrawlCrate update call
                    somethingDone = true;
                    Task t2 = Updater.CheckUpdate(args[1] != "0", args[2], args[3] != "0", args[4], args[5] != "0",
                                                  args[6] != "0");
                    t2.Wait();
                    break;

                case "-buc":     //BrawlCrate Canary update call
                    somethingDone = true;
                    Task t2c = Updater.CheckCanaryUpdate(args.Length > 1 ? args[1] : null,
                                                         args.Length > 2 && args[2] != "0", false);
                    t2c.Wait();
                    break;

                case "-bi":     //BrawlCrate issue call
                    somethingDone = true;
                    Task t3 = BugSquish.CreateIssue(args[1], args[2], args[3], args[4], args[5]);
                    t3.Wait();
                    break;

                case "-bcommitTime":     //Called on build to ensure time is saved
                    somethingDone = true;
                    string t4arg1 = args.Length > 1 ? args[1] : null;
                    string t4arg2 = args.Length > 2 ? args[2] : null;
                    string t4arg3 = args.Length > 3 ? args[3] : null;
                    string t4arg4 = args.Length > 4 ? args[4] : null;

                    Task t4 = Updater.WriteCanaryTime(t4arg1, t4arg2, t4arg3, t4arg4);
                    t4.Wait();
                    break;

                case "-dlCanary":     // Force download the latest Canary build
                    somethingDone = true;
                    Task t5a = Updater.SetCanaryActive();
                    t5a.Wait();
                    Task t5 = Updater.CheckCanaryUpdate(args.Length > 1 ? args[1] : null, false, true);
                    t5.Wait();
                    break;

                case "-dlStable":     // Force download the latest Stable build
                    somethingDone = true;
                    Task t6a = Updater.SetCanaryInactive();
                    t6a.Wait();
                    Task t6 = Updater.ForceDownloadStable(args.Length > 1 ? args[1] : null);
                    t6.Wait();
                    break;

                case "-dlDoc":     // Force download the latest Documentation build
                    somethingDone = true;
                    Task t6d = Updater.ForceDownloadDocumentation();
                    t6d.Wait();
                    break;

                case "-canarylog":     // Show changelog for canary
                    somethingDone = true;
                    Task t7 = Updater.ShowCanaryChangelog();
                    t7.Wait();
                    break;

                case "-canaryOn":     // Activate canary build
                    somethingDone = true;
                    Task t8 = Updater.SetCanaryActive();
                    t8.Wait();
                    break;

                case "-canaryOff":
                    somethingDone = true;
                    Task t9 = Updater.SetCanaryInactive();
                    t9.Wait();
                    break;

                case "-killAll":
                    somethingDone = true;
                    Task t10 = Updater.KillOpenWindows();
                    t10.Wait();
                    break;
                }
            }
            else if (args.Length == 0)
            {
                somethingDone = true;
#if CANARY
                Task t = Updater.CheckCanaryUpdate("", true, false);
#else
                Task t = Updater.CheckUpdate(true);
#endif
                t.Wait();
            }

            if (!somethingDone)
            {
                Console.WriteLine(Usage);
            }
        }