BEurtle.BEurtlePlugin.OnCommitFinished C# (CSharp) Method

OnCommitFinished() public method

public OnCommitFinished ( IntPtr hParentWnd, string commonRoot, string pathList, string logMessage, int revision ) : string
hParentWnd System.IntPtr
commonRoot string
pathList string
logMessage string
revision int
return string
        public string OnCommitFinished(IntPtr hParentWnd, string commonRoot, string[] pathList, string logMessage, int revision)
        {
            var hwnd = hParentWnd != IntPtr.Zero ? new Win32Window(hParentWnd) : null;
            rootpath = commonRoot;
            if (logMessage.ToLower().IndexOf("fixed") >= 0)
            {
                var regexObj = new Regex(@"[\s;,.]([0-9a-f]{3}/[0-9a-f]{3})[\s;,.]", RegexOptions.IgnoreCase);
                var matches = regexObj.Matches(logMessage);

                if (matches.Count > 0)
                {
                    bool modified = false;
                    if(parameters==null) parameters = new ParseParameters(this, hwnd, "");
                    if (VCSAuthor == null)
                    {
                        string VCSUser_ = callBEcmd(rootpath, new string[1] { "vcs get_user_id" })[0];
                        if (-1 != VCSUser_.IndexOf("RESULT:"))
                            this.parameters.DefaultAuthor = VCSAuthor = VCSUser_.Substring(VCSUser_.IndexOf("RESULT:") + 8);
                    }
                    if (issues == null && !loadIssues(hwnd))
                        throw new Exception("Failed to load BE issues for checking commit message against");
                    var openstatuses=new List<string>() { "unconfirmed", "open", "assigned", "test" };
                    var itemsdone = new List<string>();
                    foreach (Match match in matches)
                    {
                        string shortname = match.Groups[1].ToString();
                        if (!itemsdone.Contains(shortname))
                        {
                            BEIssue issue = findIssues(new string[1] { shortname })[0];
                            if (openstatuses.Contains(issue.status))
                            {
                                var result = MessageBox.Show(hwnd, "Commit message implies issue " + shortname + " (" + issue.summary + ")\nwith status " + issue.status + " is now fixed. Shall I mark it as fixed for you?", "Question", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                                if (DialogResult.Cancel == result)
                                    break;
                                else if (DialogResult.Yes == result)
                                {
                                    string[] outputs;
                                    if(parameters.AddCommitAsComment)
                                        outputs = callBEcmd(rootpath, new string[1] { "comment -a \"BEurtle auto issue closer\" " + shortname + " -" }, new string[1] { "Fixed in commit "+revision.ToString("x")+" (decimal "+revision.ToString()+")" });
                                    outputs = callBEcmd(rootpath, new string[1] { "status fixed " + shortname });
                                    if (outputs[0].Length > 0) MessageBox.Show(hwnd, "Command output: " + outputs[0]);
                                    else
                                    {
                                        itemsdone.Add(shortname);
                                        modified = true;
                                    }
                                }
                            }
                        }
                    }
                    if (modified)
                        writeHTML(hwnd, rootpath);
                }
            }
            return null;
        }